<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP, ForeignFunctionInterface #-}</span><span class="hs-cpp">
#if __GLASGOW_HASKELL__ &gt;= 709
</span><span class="hs-pragma">{-# LANGUAGE Safe #-}</span><span class="hs-cpp">
#else
</span><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span class="hs-cpp">
#endif
</span><span class="hs-pragma">{-# LANGUAGE InterruptibleFFI #-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Module      :  System.Process</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow 2004-2008</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Stability   :  experimental</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- Portability :  non-portable (requires concurrency)</span><span>
</span><span id="line-18"></span><span class="hs-comment">--</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- Operations for creating and interacting with sub-processes.</span><span>
</span><span id="line-20"></span><span class="hs-comment">--</span><span>
</span><span id="line-21"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span class="hs-comment">-- ToDo:</span><span>
</span><span id="line-24"></span><span class="hs-comment">--      * Flag to control whether exiting the parent also kills the child.</span><span>
</span><span id="line-25"></span><span>
</span><span id="line-26"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">System.Process</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-27"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Running sub-processes</span></span><span>
</span><span id="line-28"></span><span>    </span><span class="annot"><a href="System.Process.html#createProcess"><span class="hs-identifier">createProcess</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-29"></span><span>    </span><span class="annot"><a href="System.Process.Internals.html#createProcess_"><span class="hs-identifier">createProcess_</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>    </span><span class="annot"><a href="System.Process.html#shell"><span class="hs-identifier">shell</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Process.html#proc"><span class="hs-identifier">proc</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>    </span><span class="annot"><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier">CreateProcess</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>    </span><span class="annot"><a href="System.Process.Common.html#CmdSpec"><span class="hs-identifier">CmdSpec</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>    </span><span class="annot"><a href="System.Process.Common.html#StdStream"><span class="hs-identifier">StdStream</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>    </span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier">ProcessHandle</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span>    </span><span class="annot"><span class="hs-comment">-- ** Simpler functions for common tasks</span></span><span>
</span><span id="line-37"></span><span>    </span><span class="annot"><a href="System.Process.html#callProcess"><span class="hs-identifier">callProcess</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-38"></span><span>    </span><span class="annot"><a href="System.Process.html#callCommand"><span class="hs-identifier">callCommand</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>    </span><span class="annot"><a href="System.Process.html#spawnProcess"><span class="hs-identifier">spawnProcess</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-40"></span><span>    </span><span class="annot"><a href="System.Process.html#spawnCommand"><span class="hs-identifier">spawnCommand</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-41"></span><span>    </span><span class="annot"><a href="System.Process.html#readCreateProcess"><span class="hs-identifier">readCreateProcess</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>    </span><span class="annot"><a href="System.Process.html#readProcess"><span class="hs-identifier">readProcess</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>    </span><span class="annot"><a href="System.Process.html#readCreateProcessWithExitCode"><span class="hs-identifier">readCreateProcessWithExitCode</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-44"></span><span>    </span><span class="annot"><a href="System.Process.html#readProcessWithExitCode"><span class="hs-identifier">readProcessWithExitCode</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-45"></span><span>    </span><span class="annot"><a href="System.Process.html#withCreateProcess"><span class="hs-identifier">withCreateProcess</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-46"></span><span>    </span><span class="annot"><a href="System.Process.html#cleanupProcess"><span class="hs-identifier">cleanupProcess</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-47"></span><span>
</span><span id="line-48"></span><span>    </span><span class="annot"><span class="hs-comment">-- ** Related utilities</span></span><span>
</span><span id="line-49"></span><span>    </span><span class="annot"><a href="System.Process.html#showCommandForUser"><span class="hs-identifier">showCommandForUser</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-50"></span><span>    </span><span class="annot"><a href="System.Process.html#Pid"><span class="hs-identifier">Pid</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-51"></span><span>    </span><span class="annot"><a href="System.Process.html#getPid"><span class="hs-identifier">getPid</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-52"></span><span>    </span><span class="annot"><a href="System.Process.html#getCurrentPid"><span class="hs-identifier">getCurrentPid</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-53"></span><span>
</span><span id="line-54"></span><span>    </span><span class="annot"><span class="hs-comment">-- ** Control-C handling on Unix</span></span><span>
</span><span id="line-55"></span><span>    </span><span class="annot"><span class="hs-comment">-- $ctlc-handling</span></span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Process completion</span></span><span>
</span><span id="line-58"></span><span>    </span><span class="annot"><span class="hs-comment">-- ** Notes about @exec@ on Windows</span></span><span>
</span><span id="line-59"></span><span>    </span><span class="annot"><span class="hs-comment">-- $exec-on-windows</span></span><span>
</span><span id="line-60"></span><span>    </span><span class="annot"><a href="System.Process.html#waitForProcess"><span class="hs-identifier">waitForProcess</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-61"></span><span>    </span><span class="annot"><a href="System.Process.html#getProcessExitCode"><span class="hs-identifier">getProcessExitCode</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-62"></span><span>    </span><span class="annot"><a href="System.Process.html#terminateProcess"><span class="hs-identifier">terminateProcess</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-63"></span><span>    </span><span class="annot"><a href="System.Process.Internals.html#interruptProcessGroupOf"><span class="hs-identifier">interruptProcessGroupOf</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-64"></span><span>
</span><span id="line-65"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Interprocess communication</span></span><span>
</span><span id="line-66"></span><span>    </span><span class="annot"><a href="System.Process.Internals.html#createPipe"><span class="hs-identifier">createPipe</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-67"></span><span>    </span><span class="annot"><a href="System.Process.Internals.html#createPipeFd"><span class="hs-identifier">createPipeFd</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Old deprecated functions</span></span><span>
</span><span id="line-70"></span><span>    </span><span class="hs-comment">-- | These functions pre-date 'createProcess' which is much more</span><span>
</span><span id="line-71"></span><span>    </span><span class="hs-comment">-- flexible.</span><span>
</span><span id="line-72"></span><span>    </span><span class="annot"><a href="System.Process.html#runProcess"><span class="hs-identifier">runProcess</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-73"></span><span>    </span><span class="annot"><a href="System.Process.html#runCommand"><span class="hs-identifier">runCommand</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-74"></span><span>    </span><span class="annot"><a href="System.Process.html#runInteractiveProcess"><span class="hs-identifier">runInteractiveProcess</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-75"></span><span>    </span><span class="annot"><a href="System.Process.html#runInteractiveCommand"><span class="hs-identifier">runInteractiveCommand</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-76"></span><span>    </span><span class="annot"><a href="System.Process.html#system"><span class="hs-identifier">system</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-77"></span><span>    </span><span class="annot"><a href="System.Process.html#rawSystem"><span class="hs-identifier">rawSystem</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-78"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-79"></span><span>
</span><span id="line-80"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Prelude.html#"><span class="hs-identifier">Prelude</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier">mapM</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Process.Internals.html"><span class="hs-identifier">System.Process.Internals</span></a></span><span>
</span><span id="line-83"></span><span>
</span><span id="line-84"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Concurrent.html#"><span class="hs-identifier">Control.Concurrent</span></a></span><span>
</span><span id="line-85"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../deepseq/src/Control.DeepSeq.html#"><span class="hs-identifier">Control.DeepSeq</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../deepseq/src/Control.DeepSeq.html#rnf"><span class="hs-identifier">rnf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-86"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Exception.Type.html#SomeException"><span class="hs-identifier">SomeException</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#mask"><span class="hs-identifier">mask</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#allowInterrupt"><span class="hs-identifier">allowInterrupt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.Base.html#bracket"><span class="hs-identifier">bracket</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.Base.html#try"><span class="hs-identifier">try</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#throwIO"><span class="hs-identifier">throwIO</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-87"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">C</span></span><span>
</span><span id="line-88"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-89"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#"><span class="hs-identifier">Data.Maybe</span></a></span><span>
</span><span id="line-90"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.html#"><span class="hs-identifier">Foreign</span></a></span><span>
</span><span id="line-91"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.html#"><span class="hs-identifier">Foreign.C</span></a></span><span>
</span><span id="line-92"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.Exit.html#"><span class="hs-identifier">System.Exit</span></a></span><span>      </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ExitCode"><span class="hs-identifier">ExitCode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-93"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#"><span class="hs-identifier">System.IO</span></a></span><span>
</span><span id="line-94"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.Error.html#"><span class="hs-identifier">System.IO.Error</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/System.IO.Error.html#mkIOError"><span class="hs-identifier">mkIOError</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.Error.html#ioeSetErrorString"><span class="hs-identifier">ioeSetErrorString</span></a></span><span class="hs-special">)</span><span class="hs-cpp">

#if defined(WINDOWS)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Process.html#"><span class="hs-identifier">System.Win32.Process</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../Win32/src/System.Win32.Process.html#getProcessId"><span class="hs-identifier">getProcessId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Process.html#getCurrentProcessId"><span class="hs-identifier">getCurrentProcessId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Process.html#ProcessId"><span class="hs-identifier">ProcessId</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Posix.Process</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">getProcessID</span><span class="hs-special">)</span><span>
</span><span id="line-100"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Posix.Types</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">CPid</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-103"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#"><span class="hs-identifier">GHC.IO.Exception</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ioException"><span class="hs-identifier">ioException</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#IOErrorType"><span class="hs-identifier">IOErrorType</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#IOException"><span class="hs-identifier">IOException</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-104"></span><span>
</span><span id="line-105"></span><span class="hs-comment">-- | The platform specific type for a process identifier.</span><span>
</span><span id="line-106"></span><span class="hs-comment">--</span><span>
</span><span id="line-107"></span><span class="hs-comment">-- This is always an integral type. Width and signedness are platform specific.</span><span>
</span><span id="line-108"></span><span class="hs-comment">--</span><span>
</span><span id="line-109"></span><span class="hs-comment">-- @since 1.6.3.0</span><span class="hs-cpp">
#if defined(WINDOWS)
</span><span class="hs-keyword">type</span><span> </span><span id="Pid"><span class="annot"><a href="System.Process.html#Pid"><span class="hs-identifier hs-var">Pid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Process.html#ProcessId"><span class="hs-identifier hs-type">ProcessId</span></a></span><span class="hs-cpp">
#else
</span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">Pid</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">CPid</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-116"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-117"></span><span class="hs-comment">-- createProcess</span><span>
</span><span id="line-118"></span><span>
</span><span id="line-119"></span><span class="hs-comment">-- | Construct a 'CreateProcess' record for passing to 'createProcess',</span><span>
</span><span id="line-120"></span><span class="hs-comment">-- representing a raw command with arguments.</span><span>
</span><span id="line-121"></span><span class="hs-comment">--</span><span>
</span><span id="line-122"></span><span class="hs-comment">-- See 'RawCommand' for precise semantics of the specified @FilePath@.</span><span>
</span><span id="line-123"></span><span class="annot"><a href="System.Process.html#proc"><span class="hs-identifier hs-type">proc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier hs-type">CreateProcess</span></a></span><span>
</span><span id="line-124"></span><span id="proc"><span class="annot"><span class="annottext">proc :: String -&gt; [String] -&gt; CreateProcess
</span><a href="System.Process.html#proc"><span class="hs-identifier hs-var hs-var">proc</span></a></span></span><span> </span><span id="local-6989586621679048577"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048577"><span class="hs-identifier hs-var">cmd</span></a></span></span><span> </span><span id="local-6989586621679048576"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048576"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CreateProcess :: CmdSpec
-&gt; Maybe String
-&gt; Maybe [(String, String)]
-&gt; StdStream
-&gt; StdStream
-&gt; StdStream
-&gt; Bool
-&gt; Bool
-&gt; Bool
-&gt; Bool
-&gt; Bool
-&gt; Bool
-&gt; Maybe GroupID
-&gt; Maybe GroupID
-&gt; Bool
-&gt; CreateProcess
</span><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier hs-type">CreateProcess</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cmdspec :: CmdSpec
</span><a href="System.Process.Common.html#cmdspec"><span class="hs-identifier hs-var">cmdspec</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; CmdSpec
</span><a href="System.Process.Common.html#RawCommand"><span class="hs-identifier hs-var">RawCommand</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048577"><span class="hs-identifier hs-var">cmd</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048576"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-125"></span><span>                                </span><span class="annot"><span class="annottext">cwd :: Maybe String
</span><a href="System.Process.Common.html#cwd"><span class="hs-identifier hs-var">cwd</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-126"></span><span>                                </span><span class="annot"><span class="annottext">env :: Maybe [(String, String)]
</span><a href="System.Process.Common.html#env"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe [(String, String)]
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-127"></span><span>                                </span><span class="annot"><span class="annottext">std_in :: StdStream
</span><a href="System.Process.Common.html#std_in"><span class="hs-identifier hs-var">std_in</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#Inherit"><span class="hs-identifier hs-var">Inherit</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-128"></span><span>                                </span><span class="annot"><span class="annottext">std_out :: StdStream
</span><a href="System.Process.Common.html#std_out"><span class="hs-identifier hs-var">std_out</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#Inherit"><span class="hs-identifier hs-var">Inherit</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-129"></span><span>                                </span><span class="annot"><span class="annottext">std_err :: StdStream
</span><a href="System.Process.Common.html#std_err"><span class="hs-identifier hs-var">std_err</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#Inherit"><span class="hs-identifier hs-var">Inherit</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-130"></span><span>                                </span><span class="annot"><span class="annottext">close_fds :: Bool
</span><a href="System.Process.Common.html#close_fds"><span class="hs-identifier hs-var">close_fds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-131"></span><span>                                </span><span class="annot"><span class="annottext">create_group :: Bool
</span><a href="System.Process.Common.html#create_group"><span class="hs-identifier hs-var">create_group</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-132"></span><span>                                </span><span class="annot"><span class="annottext">delegate_ctlc :: Bool
</span><a href="System.Process.Common.html#delegate_ctlc"><span class="hs-identifier hs-var">delegate_ctlc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-133"></span><span>                                </span><span class="annot"><span class="annottext">detach_console :: Bool
</span><a href="System.Process.Common.html#detach_console"><span class="hs-identifier hs-var">detach_console</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-134"></span><span>                                </span><span class="annot"><span class="annottext">create_new_console :: Bool
</span><a href="System.Process.Common.html#create_new_console"><span class="hs-identifier hs-var">create_new_console</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-135"></span><span>                                </span><span class="annot"><span class="annottext">new_session :: Bool
</span><a href="System.Process.Common.html#new_session"><span class="hs-identifier hs-var">new_session</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-136"></span><span>                                </span><span class="annot"><span class="annottext">child_group :: Maybe GroupID
</span><a href="System.Process.Common.html#child_group"><span class="hs-identifier hs-var">child_group</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe GroupID
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-137"></span><span>                                </span><span class="annot"><span class="annottext">child_user :: Maybe GroupID
</span><a href="System.Process.Common.html#child_user"><span class="hs-identifier hs-var">child_user</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe GroupID
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-138"></span><span>                                </span><span class="annot"><span class="annottext">use_process_jobs :: Bool
</span><a href="System.Process.Common.html#use_process_jobs"><span class="hs-identifier hs-var">use_process_jobs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-139"></span><span>
</span><span id="line-140"></span><span class="hs-comment">-- | Construct a 'CreateProcess' record for passing to 'createProcess',</span><span>
</span><span id="line-141"></span><span class="hs-comment">-- representing a command to be passed to the shell.</span><span>
</span><span id="line-142"></span><span class="annot"><a href="System.Process.html#shell"><span class="hs-identifier hs-type">shell</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier hs-type">CreateProcess</span></a></span><span>
</span><span id="line-143"></span><span id="shell"><span class="annot"><span class="annottext">shell :: String -&gt; CreateProcess
</span><a href="System.Process.html#shell"><span class="hs-identifier hs-var hs-var">shell</span></a></span></span><span> </span><span id="local-6989586621679048557"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048557"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CreateProcess :: CmdSpec
-&gt; Maybe String
-&gt; Maybe [(String, String)]
-&gt; StdStream
-&gt; StdStream
-&gt; StdStream
-&gt; Bool
-&gt; Bool
-&gt; Bool
-&gt; Bool
-&gt; Bool
-&gt; Bool
-&gt; Maybe GroupID
-&gt; Maybe GroupID
-&gt; Bool
-&gt; CreateProcess
</span><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier hs-type">CreateProcess</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cmdspec :: CmdSpec
</span><a href="System.Process.Common.html#cmdspec"><span class="hs-identifier hs-var">cmdspec</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; CmdSpec
</span><a href="System.Process.Common.html#ShellCommand"><span class="hs-identifier hs-var">ShellCommand</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048557"><span class="hs-identifier hs-var">str</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-144"></span><span>                            </span><span class="annot"><span class="annottext">cwd :: Maybe String
</span><a href="System.Process.Common.html#cwd"><span class="hs-identifier hs-var">cwd</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-145"></span><span>                            </span><span class="annot"><span class="annottext">env :: Maybe [(String, String)]
</span><a href="System.Process.Common.html#env"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe [(String, String)]
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-146"></span><span>                            </span><span class="annot"><span class="annottext">std_in :: StdStream
</span><a href="System.Process.Common.html#std_in"><span class="hs-identifier hs-var">std_in</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#Inherit"><span class="hs-identifier hs-var">Inherit</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-147"></span><span>                            </span><span class="annot"><span class="annottext">std_out :: StdStream
</span><a href="System.Process.Common.html#std_out"><span class="hs-identifier hs-var">std_out</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#Inherit"><span class="hs-identifier hs-var">Inherit</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-148"></span><span>                            </span><span class="annot"><span class="annottext">std_err :: StdStream
</span><a href="System.Process.Common.html#std_err"><span class="hs-identifier hs-var">std_err</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#Inherit"><span class="hs-identifier hs-var">Inherit</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-149"></span><span>                            </span><span class="annot"><span class="annottext">close_fds :: Bool
</span><a href="System.Process.Common.html#close_fds"><span class="hs-identifier hs-var">close_fds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-150"></span><span>                            </span><span class="annot"><span class="annottext">create_group :: Bool
</span><a href="System.Process.Common.html#create_group"><span class="hs-identifier hs-var">create_group</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-151"></span><span>                            </span><span class="annot"><span class="annottext">delegate_ctlc :: Bool
</span><a href="System.Process.Common.html#delegate_ctlc"><span class="hs-identifier hs-var">delegate_ctlc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-152"></span><span>                            </span><span class="annot"><span class="annottext">detach_console :: Bool
</span><a href="System.Process.Common.html#detach_console"><span class="hs-identifier hs-var">detach_console</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-153"></span><span>                            </span><span class="annot"><span class="annottext">create_new_console :: Bool
</span><a href="System.Process.Common.html#create_new_console"><span class="hs-identifier hs-var">create_new_console</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-154"></span><span>                            </span><span class="annot"><span class="annottext">new_session :: Bool
</span><a href="System.Process.Common.html#new_session"><span class="hs-identifier hs-var">new_session</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-155"></span><span>                            </span><span class="annot"><span class="annottext">child_group :: Maybe GroupID
</span><a href="System.Process.Common.html#child_group"><span class="hs-identifier hs-var">child_group</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe GroupID
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-156"></span><span>                            </span><span class="annot"><span class="annottext">child_user :: Maybe GroupID
</span><a href="System.Process.Common.html#child_user"><span class="hs-identifier hs-var">child_user</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe GroupID
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-157"></span><span>                            </span><span class="annot"><span class="annottext">use_process_jobs :: Bool
</span><a href="System.Process.Common.html#use_process_jobs"><span class="hs-identifier hs-var">use_process_jobs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-158"></span><span>
</span><span id="line-159"></span><span class="hs-comment">{- |
This is the most general way to spawn an external process.  The
process can be a command line to be executed by a shell or a raw command
with a list of arguments.  The stdin, stdout, and stderr streams of
the new process may individually be attached to new pipes, to existing
'Handle's, or just inherited from the parent (the default.)

The details of how to create the process are passed in the
'CreateProcess' record.  To make it easier to construct a
'CreateProcess', the functions 'proc' and 'shell' are supplied that
fill in the fields with default values which can be overriden as
needed.

'createProcess' returns @(/mb_stdin_hdl/, /mb_stdout_hdl/, /mb_stderr_hdl/, /ph/)@,
where

 * if @'std_in' == 'CreatePipe'@, then @/mb_stdin_hdl/@ will be @Just /h/@,
   where @/h/@ is the write end of the pipe connected to the child
   process's @stdin@.

 * otherwise, @/mb_stdin_hdl/ == Nothing@

Similarly for @/mb_stdout_hdl/@ and @/mb_stderr_hdl/@.

For example, to execute a simple @ls@ command:

&gt;   r &lt;- createProcess (proc &quot;ls&quot; [])

To create a pipe from which to read the output of @ls@:

&gt;   (_, Just hout, _, _) &lt;-
&gt;       createProcess (proc &quot;ls&quot; []){ std_out = CreatePipe }

To also set the directory in which to run @ls@:

&gt;   (_, Just hout, _, _) &lt;-
&gt;       createProcess (proc &quot;ls&quot; []){ cwd = Just &quot;/home/bob&quot;,
&gt;                                     std_out = CreatePipe }

Note that @Handle@s provided for @std_in@, @std_out@, or @std_err@ via the
@UseHandle@ constructor will be closed by calling this function. This is not
always the desired behavior. In cases where you would like to leave the
@Handle@ open after spawning the child process, please use 'createProcess_'
instead. All created @Handle@s are initially in text mode; if you need them
to be in binary mode then use 'hSetBinaryMode'.

@/ph/@ contains a handle to the running process.  On Windows
'use_process_jobs' can be set in CreateProcess in order to create a
Win32 Job object to monitor a process tree's progress.  If it is set
then that job is also returned inside @/ph/@.  @/ph/@ can be used to
kill all running sub-processes.  This feature has been available since
1.5.0.0.

-}</span><span>
</span><span id="line-213"></span><span class="annot"><a href="System.Process.html#createProcess"><span class="hs-identifier hs-type">createProcess</span></a></span><span>
</span><span id="line-214"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier hs-type">CreateProcess</span></a></span><span>
</span><span id="line-215"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-216"></span><span id="createProcess"><span class="annot"><span class="annottext">createProcess :: CreateProcess
-&gt; IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
</span><a href="System.Process.html#createProcess"><span class="hs-identifier hs-var hs-var">createProcess</span></a></span></span><span> </span><span id="local-6989586621679048555"><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048555"><span class="hs-identifier hs-var">cp</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-217"></span><span>  </span><span id="local-6989586621679048554"><span class="annot"><span class="annottext">(Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
</span><a href="#local-6989586621679048554"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String
-&gt; CreateProcess
-&gt; IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
</span><a href="System.Process.Internals.html#createProcess_"><span class="hs-identifier hs-var">createProcess_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;createProcess&quot;</span></span><span> </span><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048555"><span class="hs-identifier hs-var">cp</span></a></span><span>
</span><span id="line-218"></span><span>  </span><span class="annot"><span class="annottext">StdStream -&gt; IO ()
</span><a href="#local-6989586621679048553"><span class="hs-identifier hs-var">maybeCloseStd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CreateProcess -&gt; StdStream
</span><a href="System.Process.Common.html#std_in"><span class="hs-identifier hs-var hs-var">std_in</span></a></span><span>  </span><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048555"><span class="hs-identifier hs-var">cp</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-219"></span><span>  </span><span class="annot"><span class="annottext">StdStream -&gt; IO ()
</span><a href="#local-6989586621679048553"><span class="hs-identifier hs-var">maybeCloseStd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CreateProcess -&gt; StdStream
</span><a href="System.Process.Common.html#std_out"><span class="hs-identifier hs-var hs-var">std_out</span></a></span><span> </span><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048555"><span class="hs-identifier hs-var">cp</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-220"></span><span>  </span><span class="annot"><span class="annottext">StdStream -&gt; IO ()
</span><a href="#local-6989586621679048553"><span class="hs-identifier hs-var">maybeCloseStd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CreateProcess -&gt; StdStream
</span><a href="System.Process.Common.html#std_err"><span class="hs-identifier hs-var hs-var">std_err</span></a></span><span> </span><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048555"><span class="hs-identifier hs-var">cp</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-221"></span><span>  </span><span class="annot"><span class="annottext">(Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
-&gt; IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
</span><a href="#local-6989586621679048554"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-222"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-223"></span><span>  </span><span class="annot"><a href="#local-6989586621679048553"><span class="hs-identifier hs-type">maybeCloseStd</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Process.Common.html#StdStream"><span class="hs-identifier hs-type">StdStream</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-224"></span><span>  </span><span id="local-6989586621679048553"><span class="annot"><span class="annottext">maybeCloseStd :: StdStream -&gt; IO ()
</span><a href="#local-6989586621679048553"><span class="hs-identifier hs-var hs-var">maybeCloseStd</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="System.Process.Common.html#UseHandle"><span class="hs-identifier hs-type">UseHandle</span></a></span><span> </span><span id="local-6989586621679048551"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048551"><span class="hs-identifier hs-var">hdl</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-225"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048551"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Handle -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#stdin"><span class="hs-identifier hs-var">stdin</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048551"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Handle -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#stdout"><span class="hs-identifier hs-var">stdout</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048551"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Handle -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#stderr"><span class="hs-identifier hs-var">stderr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048551"><span class="hs-identifier hs-var">hdl</span></a></span><span>
</span><span id="line-226"></span><span>  </span><span class="annot"><a href="#local-6989586621679048553"><span class="hs-identifier hs-var">maybeCloseStd</span></a></span><span> </span><span class="annot"><span class="annottext">StdStream
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-227"></span><span>
</span><span id="line-228"></span><span class="hs-comment">-- | A 'C.bracket'-style resource handler for 'createProcess'.</span><span>
</span><span id="line-229"></span><span class="hs-comment">--</span><span>
</span><span id="line-230"></span><span class="hs-comment">-- Does automatic cleanup when the action finishes. If there is an exception</span><span>
</span><span id="line-231"></span><span class="hs-comment">-- in the body then it ensures that the process gets terminated and any</span><span>
</span><span id="line-232"></span><span class="hs-comment">-- 'CreatePipe' 'Handle's are closed. In particular this means that if the</span><span>
</span><span id="line-233"></span><span class="hs-comment">-- Haskell thread is killed (e.g. 'killThread'), that the external process is</span><span>
</span><span id="line-234"></span><span class="hs-comment">-- also terminated.</span><span>
</span><span id="line-235"></span><span class="hs-comment">--</span><span>
</span><span id="line-236"></span><span class="hs-comment">-- e.g.</span><span>
</span><span id="line-237"></span><span class="hs-comment">--</span><span>
</span><span id="line-238"></span><span class="hs-comment">-- &gt; withCreateProcess (proc cmd args) { ... }  $ \stdin stdout stderr ph -&gt; do</span><span>
</span><span id="line-239"></span><span class="hs-comment">-- &gt;   ...</span><span>
</span><span id="line-240"></span><span class="hs-comment">--</span><span>
</span><span id="line-241"></span><span class="hs-comment">-- @since 1.4.3.0</span><span>
</span><span id="line-242"></span><span id="local-6989586621679048873"><span class="annot"><a href="System.Process.html#withCreateProcess"><span class="hs-identifier hs-type">withCreateProcess</span></a></span><span>
</span><span id="line-243"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier hs-type">CreateProcess</span></a></span><span>
</span><span id="line-244"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679048873"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-245"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679048873"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-246"></span><span id="withCreateProcess"><span class="annot"><span class="annottext">withCreateProcess :: forall a.
CreateProcess
-&gt; (Maybe Handle
    -&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO a)
-&gt; IO a
</span><a href="System.Process.html#withCreateProcess"><span class="hs-identifier hs-var hs-var">withCreateProcess</span></a></span></span><span> </span><span id="local-6989586621679048544"><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048544"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span id="local-6989586621679048543"><span class="annot"><span class="annottext">Maybe Handle
-&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO a
</span><a href="#local-6989586621679048543"><span class="hs-identifier hs-var">action</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-247"></span><span>    </span><span class="annot"><span class="annottext">IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
-&gt; ((Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
    -&gt; IO ())
-&gt; ((Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
    -&gt; IO a)
-&gt; IO a
forall a b c. IO a -&gt; (a -&gt; IO b) -&gt; (a -&gt; IO c) -&gt; IO c
</span><a href="../../base/src/Control.Exception.Base.html#bracket"><span class="hs-identifier hs-var">C.bracket</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CreateProcess
-&gt; IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
</span><a href="System.Process.html#createProcess"><span class="hs-identifier hs-var">createProcess</span></a></span><span> </span><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048544"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -&gt; IO ()
</span><a href="System.Process.html#cleanupProcess"><span class="hs-identifier hs-var">cleanupProcess</span></a></span><span>
</span><span id="line-248"></span><span>              </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621679048542"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048542"><span class="hs-identifier hs-var">m_in</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048541"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048541"><span class="hs-identifier hs-var">m_out</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048540"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048540"><span class="hs-identifier hs-var">m_err</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048539"><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048539"><span class="hs-identifier hs-var">ph</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Handle
-&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO a
</span><a href="#local-6989586621679048543"><span class="hs-identifier hs-var">action</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048542"><span class="hs-identifier hs-var">m_in</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048541"><span class="hs-identifier hs-var">m_out</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048540"><span class="hs-identifier hs-var">m_err</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048539"><span class="hs-identifier hs-var">ph</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-249"></span><span>
</span><span id="line-250"></span><span class="hs-comment">-- wrapper so we can get exceptions with the appropriate function name.</span><span>
</span><span id="line-251"></span><span id="local-6989586621679048868"><span class="annot"><a href="System.Process.html#withCreateProcess_"><span class="hs-identifier hs-type">withCreateProcess_</span></a></span><span>
</span><span id="line-252"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-253"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier hs-type">CreateProcess</span></a></span><span>
</span><span id="line-254"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679048868"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-255"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679048868"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-256"></span><span id="withCreateProcess_"><span class="annot"><span class="annottext">withCreateProcess_ :: forall a.
String
-&gt; CreateProcess
-&gt; (Maybe Handle
    -&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO a)
-&gt; IO a
</span><a href="System.Process.html#withCreateProcess_"><span class="hs-identifier hs-var hs-var">withCreateProcess_</span></a></span></span><span> </span><span id="local-6989586621679048537"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048537"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span id="local-6989586621679048536"><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048536"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span id="local-6989586621679048535"><span class="annot"><span class="annottext">Maybe Handle
-&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO a
</span><a href="#local-6989586621679048535"><span class="hs-identifier hs-var">action</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-257"></span><span>    </span><span class="annot"><span class="annottext">IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
-&gt; ((Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
    -&gt; IO ())
-&gt; ((Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
    -&gt; IO a)
-&gt; IO a
forall a b c. IO a -&gt; (a -&gt; IO b) -&gt; (a -&gt; IO c) -&gt; IO c
</span><a href="../../base/src/Control.Exception.Base.html#bracketOnError"><span class="hs-identifier hs-var">C.bracketOnError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
-&gt; CreateProcess
-&gt; IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
</span><a href="System.Process.Internals.html#createProcess_"><span class="hs-identifier hs-var">createProcess_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048537"><span class="hs-identifier hs-var">fun</span></a></span><span> </span><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048536"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -&gt; IO ()
</span><a href="System.Process.html#cleanupProcess"><span class="hs-identifier hs-var">cleanupProcess</span></a></span><span>
</span><span id="line-258"></span><span>                     </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621679048533"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048533"><span class="hs-identifier hs-var">m_in</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048532"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048532"><span class="hs-identifier hs-var">m_out</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048531"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048531"><span class="hs-identifier hs-var">m_err</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048530"><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048530"><span class="hs-identifier hs-var">ph</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Handle
-&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO a
</span><a href="#local-6989586621679048535"><span class="hs-identifier hs-var">action</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048533"><span class="hs-identifier hs-var">m_in</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048532"><span class="hs-identifier hs-var">m_out</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048531"><span class="hs-identifier hs-var">m_err</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048530"><span class="hs-identifier hs-var">ph</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-259"></span><span>
</span><span id="line-260"></span><span class="hs-comment">-- | Cleans up the process.</span><span>
</span><span id="line-261"></span><span class="hs-comment">--</span><span>
</span><span id="line-262"></span><span class="hs-comment">-- This function is meant to be invoked from any application level cleanup</span><span>
</span><span id="line-263"></span><span class="hs-comment">-- handler. It terminates the process, and closes any 'CreatePipe' 'handle's.</span><span>
</span><span id="line-264"></span><span class="hs-comment">--</span><span>
</span><span id="line-265"></span><span class="hs-comment">-- @since 1.6.4.0</span><span>
</span><span id="line-266"></span><span class="annot"><a href="System.Process.html#cleanupProcess"><span class="hs-identifier hs-type">cleanupProcess</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-267"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-268"></span><span id="cleanupProcess"><span class="annot"><span class="annottext">cleanupProcess :: (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -&gt; IO ()
</span><a href="System.Process.html#cleanupProcess"><span class="hs-identifier hs-var hs-var">cleanupProcess</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679048529"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048529"><span class="hs-identifier hs-var">mb_stdin</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048528"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048528"><span class="hs-identifier hs-var">mb_stdout</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048527"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048527"><span class="hs-identifier hs-var">mb_stderr</span></a></span></span><span class="hs-special">,</span><span>
</span><span id="line-269"></span><span>                </span><span id="local-6989586621679048526"><span class="annot"><span class="annottext">ph :: ProcessHandle
</span><a href="#local-6989586621679048526"><span class="hs-identifier hs-var">ph</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span> </span><span class="annot"><span class="annottext">MVar ProcessHandle__
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679048524"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048524"><span class="hs-identifier hs-var">delegating_ctlc</span></a></span></span><span> </span><span class="annot"><span class="annottext">MVar ()
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-270"></span><span>    </span><span class="annot"><span class="annottext">ProcessHandle -&gt; IO ()
</span><a href="System.Process.html#terminateProcess"><span class="hs-identifier hs-var">terminateProcess</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048526"><span class="hs-identifier hs-var">ph</span></a></span><span>
</span><span id="line-271"></span><span>    </span><span class="hs-comment">-- Note, it's important that other threads that might be reading/writing</span><span>
</span><span id="line-272"></span><span>    </span><span class="hs-comment">-- these handles also get killed off, since otherwise they might be holding</span><span>
</span><span id="line-273"></span><span>    </span><span class="hs-comment">-- the handle lock and prevent us from closing, leading to deadlock.</span><span>
</span><span id="line-274"></span><span>    </span><span class="annot"><span class="annottext">IO () -&gt; (Handle -&gt; IO ()) -&gt; Maybe Handle -&gt; IO ()
forall b a. b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b
</span><a href="../../base/src/Data.Maybe.html#maybe"><span class="hs-identifier hs-var">maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO () -&gt; IO ()
</span><a href="System.Process.html#ignoreSigPipe"><span class="hs-identifier hs-var">ignoreSigPipe</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; (Handle -&gt; IO ()) -&gt; Handle -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048529"><span class="hs-identifier hs-var">mb_stdin</span></a></span><span>
</span><span id="line-275"></span><span>    </span><span class="annot"><span class="annottext">IO () -&gt; (Handle -&gt; IO ()) -&gt; Maybe Handle -&gt; IO ()
forall b a. b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b
</span><a href="../../base/src/Data.Maybe.html#maybe"><span class="hs-identifier hs-var">maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048528"><span class="hs-identifier hs-var">mb_stdout</span></a></span><span>
</span><span id="line-276"></span><span>    </span><span class="annot"><span class="annottext">IO () -&gt; (Handle -&gt; IO ()) -&gt; Maybe Handle -&gt; IO ()
forall b a. b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b
</span><a href="../../base/src/Data.Maybe.html#maybe"><span class="hs-identifier hs-var">maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048527"><span class="hs-identifier hs-var">mb_stderr</span></a></span><span>
</span><span id="line-277"></span><span>    </span><span class="hs-comment">-- terminateProcess does not guarantee that it terminates the process.</span><span>
</span><span id="line-278"></span><span>    </span><span class="hs-comment">-- Indeed on Unix it's SIGTERM, which asks nicely but does not guarantee</span><span>
</span><span id="line-279"></span><span>    </span><span class="hs-comment">-- that it stops. If it doesn't stop, we don't want to hang, so we wait</span><span>
</span><span id="line-280"></span><span>    </span><span class="hs-comment">-- asynchronously using forkIO.</span><span>
</span><span id="line-281"></span><span>
</span><span id="line-282"></span><span>    </span><span class="hs-comment">-- However we want to end the Ctl-C handling synchronously, so we'll do</span><span>
</span><span id="line-283"></span><span>    </span><span class="hs-comment">-- that synchronously, and set delegating_ctlc as False for the</span><span>
</span><span id="line-284"></span><span>    </span><span class="hs-comment">-- waitForProcess (which would otherwise end the Ctl-C delegation itself).</span><span>
</span><span id="line-285"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048524"><span class="hs-identifier hs-var">delegating_ctlc</span></a></span><span>
</span><span id="line-286"></span><span>      </span><span class="annot"><span class="annottext">IO ()
</span><a href="System.Process.Windows.html#stopDelegateControlC"><span class="hs-identifier hs-var">stopDelegateControlC</span></a></span><span>
</span><span id="line-287"></span><span>    </span><span class="annot"><span class="annottext">ThreadId
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO ThreadId
</span><a href="../../base/src/GHC.Conc.Sync.html#forkIO"><span class="hs-identifier hs-var">forkIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ProcessHandle -&gt; IO ExitCode
</span><a href="System.Process.html#waitForProcess"><span class="hs-identifier hs-var">waitForProcess</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ProcessHandle -&gt; ProcessHandle
</span><a href="#local-6989586621679048517"><span class="hs-identifier hs-var">resetCtlcDelegation</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048526"><span class="hs-identifier hs-var">ph</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO ExitCode -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-288"></span><span>    </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-289"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-290"></span><span>    </span><span id="local-6989586621679048517"><span class="annot"><span class="annottext">resetCtlcDelegation :: ProcessHandle -&gt; ProcessHandle
</span><a href="#local-6989586621679048517"><span class="hs-identifier hs-var hs-var">resetCtlcDelegation</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span> </span><span id="local-6989586621679048516"><span class="annot"><span class="annottext">MVar ProcessHandle__
</span><a href="#local-6989586621679048516"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679048515"><span class="annot"><span class="annottext">MVar ()
</span><a href="#local-6989586621679048515"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MVar ProcessHandle__ -&gt; Bool -&gt; MVar () -&gt; ProcessHandle
</span><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-var">ProcessHandle</span></a></span><span> </span><span class="annot"><span class="annottext">MVar ProcessHandle__
</span><a href="#local-6989586621679048516"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">MVar ()
</span><a href="#local-6989586621679048515"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-291"></span><span>
</span><span id="line-292"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-293"></span><span class="hs-comment">-- spawnProcess/spawnCommand</span><span>
</span><span id="line-294"></span><span>
</span><span id="line-295"></span><span class="hs-comment">-- | Creates a new process to run the specified raw command with the given</span><span>
</span><span id="line-296"></span><span class="hs-comment">-- arguments. It does not wait for the program to finish, but returns the</span><span>
</span><span id="line-297"></span><span class="hs-comment">-- 'ProcessHandle'.</span><span>
</span><span id="line-298"></span><span class="hs-comment">--</span><span>
</span><span id="line-299"></span><span class="hs-comment">-- @since 1.2.0.0</span><span>
</span><span id="line-300"></span><span class="annot"><a href="System.Process.html#spawnProcess"><span class="hs-identifier hs-type">spawnProcess</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span>
</span><span id="line-301"></span><span id="spawnProcess"><span class="annot"><span class="annottext">spawnProcess :: String -&gt; [String] -&gt; IO ProcessHandle
</span><a href="System.Process.html#spawnProcess"><span class="hs-identifier hs-var hs-var">spawnProcess</span></a></span></span><span> </span><span id="local-6989586621679048514"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048514"><span class="hs-identifier hs-var">cmd</span></a></span></span><span> </span><span id="local-6989586621679048513"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048513"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-302"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621679048512"><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048512"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String
-&gt; CreateProcess
-&gt; IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
</span><a href="System.Process.Internals.html#createProcess_"><span class="hs-identifier hs-var">createProcess_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;spawnProcess&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; CreateProcess
</span><a href="System.Process.html#proc"><span class="hs-identifier hs-var">proc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048514"><span class="hs-identifier hs-var">cmd</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048513"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-303"></span><span>    </span><span class="annot"><span class="annottext">ProcessHandle -&gt; IO ProcessHandle
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048512"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-304"></span><span>
</span><span id="line-305"></span><span class="hs-comment">-- | Creates a new process to run the specified shell command.</span><span>
</span><span id="line-306"></span><span class="hs-comment">-- It does not wait for the program to finish, but returns the 'ProcessHandle'.</span><span>
</span><span id="line-307"></span><span class="hs-comment">--</span><span>
</span><span id="line-308"></span><span class="hs-comment">-- @since 1.2.0.0</span><span>
</span><span id="line-309"></span><span class="annot"><a href="System.Process.html#spawnCommand"><span class="hs-identifier hs-type">spawnCommand</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span>
</span><span id="line-310"></span><span id="spawnCommand"><span class="annot"><span class="annottext">spawnCommand :: String -&gt; IO ProcessHandle
</span><a href="System.Process.html#spawnCommand"><span class="hs-identifier hs-var hs-var">spawnCommand</span></a></span></span><span> </span><span id="local-6989586621679048511"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048511"><span class="hs-identifier hs-var">cmd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-311"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621679048510"><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048510"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String
-&gt; CreateProcess
-&gt; IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
</span><a href="System.Process.Internals.html#createProcess_"><span class="hs-identifier hs-var">createProcess_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;spawnCommand&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CreateProcess
</span><a href="System.Process.html#shell"><span class="hs-identifier hs-var">shell</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048511"><span class="hs-identifier hs-var">cmd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-312"></span><span>    </span><span class="annot"><span class="annottext">ProcessHandle -&gt; IO ProcessHandle
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048510"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-313"></span><span>
</span><span id="line-314"></span><span>
</span><span id="line-315"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-316"></span><span class="hs-comment">-- callProcess/callCommand</span><span>
</span><span id="line-317"></span><span>
</span><span id="line-318"></span><span class="hs-comment">-- | Creates a new process to run the specified command with the given</span><span>
</span><span id="line-319"></span><span class="hs-comment">-- arguments, and wait for it to finish.  If the command returns a non-zero</span><span>
</span><span id="line-320"></span><span class="hs-comment">-- exit code, an exception is raised.</span><span>
</span><span id="line-321"></span><span class="hs-comment">--</span><span>
</span><span id="line-322"></span><span class="hs-comment">-- If an asynchronous exception is thrown to the thread executing</span><span>
</span><span id="line-323"></span><span class="hs-comment">-- @callProcess@, the forked process will be terminated and</span><span>
</span><span id="line-324"></span><span class="hs-comment">-- @callProcess@ will wait (block) until the process has been</span><span>
</span><span id="line-325"></span><span class="hs-comment">-- terminated.</span><span>
</span><span id="line-326"></span><span class="hs-comment">--</span><span>
</span><span id="line-327"></span><span class="hs-comment">-- @since 1.2.0.0</span><span>
</span><span id="line-328"></span><span class="annot"><a href="System.Process.html#callProcess"><span class="hs-identifier hs-type">callProcess</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-329"></span><span id="callProcess"><span class="annot"><span class="annottext">callProcess :: String -&gt; [String] -&gt; IO ()
</span><a href="System.Process.html#callProcess"><span class="hs-identifier hs-var hs-var">callProcess</span></a></span></span><span> </span><span id="local-6989586621679048509"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048509"><span class="hs-identifier hs-var">cmd</span></a></span></span><span> </span><span id="local-6989586621679048508"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048508"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-330"></span><span>    </span><span id="local-6989586621679048507"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048507"><span class="hs-identifier hs-var">exit_code</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String
-&gt; CreateProcess
-&gt; (Maybe Handle
    -&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO ExitCode)
-&gt; IO ExitCode
forall a.
String
-&gt; CreateProcess
-&gt; (Maybe Handle
    -&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO a)
-&gt; IO a
</span><a href="System.Process.html#withCreateProcess_"><span class="hs-identifier hs-var">withCreateProcess_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;callProcess&quot;</span></span><span>
</span><span id="line-331"></span><span>                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; CreateProcess
</span><a href="System.Process.html#proc"><span class="hs-identifier hs-var">proc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048509"><span class="hs-identifier hs-var">cmd</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048508"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delegate_ctlc :: Bool
</span><a href="System.Process.Common.html#delegate_ctlc"><span class="hs-identifier hs-var">delegate_ctlc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span> </span><span class="annot"><span class="annottext">((Maybe Handle
  -&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO ExitCode)
 -&gt; IO ExitCode)
-&gt; (Maybe Handle
    -&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO ExitCode)
-&gt; IO ExitCode
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679048506"><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048506"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-332"></span><span>                   </span><span class="annot"><span class="annottext">ProcessHandle -&gt; IO ExitCode
</span><a href="System.Process.html#waitForProcess"><span class="hs-identifier hs-var">waitForProcess</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048506"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-333"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048507"><span class="hs-identifier hs-var">exit_code</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-334"></span><span>      </span><span class="annot"><span class="annottext">ExitCode
</span><a href="../../base/src/GHC.IO.Exception.html#ExitSuccess"><span class="hs-identifier hs-var">ExitSuccess</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-335"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ExitFailure"><span class="hs-identifier hs-type">ExitFailure</span></a></span><span> </span><span id="local-6989586621679048503"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679048503"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; [String] -&gt; Int -&gt; IO ()
forall a. String -&gt; String -&gt; [String] -&gt; Int -&gt; IO a
</span><a href="System.Process.html#processFailedException"><span class="hs-identifier hs-var">processFailedException</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;callProcess&quot;</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048509"><span class="hs-identifier hs-var">cmd</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048508"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679048503"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-336"></span><span>
</span><span id="line-337"></span><span class="hs-comment">-- | Creates a new process to run the specified shell command.  If the</span><span>
</span><span id="line-338"></span><span class="hs-comment">-- command returns a non-zero exit code, an exception is raised.</span><span>
</span><span id="line-339"></span><span class="hs-comment">--</span><span>
</span><span id="line-340"></span><span class="hs-comment">-- If an asynchronous exception is thrown to the thread executing</span><span>
</span><span id="line-341"></span><span class="hs-comment">-- @callCommand@, the forked process will be terminated and</span><span>
</span><span id="line-342"></span><span class="hs-comment">-- @callCommand@ will wait (block) until the process has been</span><span>
</span><span id="line-343"></span><span class="hs-comment">-- terminated.</span><span>
</span><span id="line-344"></span><span class="hs-comment">--</span><span>
</span><span id="line-345"></span><span class="hs-comment">-- @since 1.2.0.0</span><span>
</span><span id="line-346"></span><span class="annot"><a href="System.Process.html#callCommand"><span class="hs-identifier hs-type">callCommand</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-347"></span><span id="callCommand"><span class="annot"><span class="annottext">callCommand :: String -&gt; IO ()
</span><a href="System.Process.html#callCommand"><span class="hs-identifier hs-var hs-var">callCommand</span></a></span></span><span> </span><span id="local-6989586621679048501"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048501"><span class="hs-identifier hs-var">cmd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-348"></span><span>    </span><span id="local-6989586621679048500"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048500"><span class="hs-identifier hs-var">exit_code</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String
-&gt; CreateProcess
-&gt; (Maybe Handle
    -&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO ExitCode)
-&gt; IO ExitCode
forall a.
String
-&gt; CreateProcess
-&gt; (Maybe Handle
    -&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO a)
-&gt; IO a
</span><a href="System.Process.html#withCreateProcess_"><span class="hs-identifier hs-var">withCreateProcess_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;callCommand&quot;</span></span><span>
</span><span id="line-349"></span><span>                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CreateProcess
</span><a href="System.Process.html#shell"><span class="hs-identifier hs-var">shell</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048501"><span class="hs-identifier hs-var">cmd</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delegate_ctlc :: Bool
</span><a href="System.Process.Common.html#delegate_ctlc"><span class="hs-identifier hs-var">delegate_ctlc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span> </span><span class="annot"><span class="annottext">((Maybe Handle
  -&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO ExitCode)
 -&gt; IO ExitCode)
-&gt; (Maybe Handle
    -&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO ExitCode)
-&gt; IO ExitCode
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679048499"><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048499"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-350"></span><span>                   </span><span class="annot"><span class="annottext">ProcessHandle -&gt; IO ExitCode
</span><a href="System.Process.html#waitForProcess"><span class="hs-identifier hs-var">waitForProcess</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048499"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-351"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048500"><span class="hs-identifier hs-var">exit_code</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-352"></span><span>      </span><span class="annot"><span class="annottext">ExitCode
</span><a href="../../base/src/GHC.IO.Exception.html#ExitSuccess"><span class="hs-identifier hs-var">ExitSuccess</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-353"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ExitFailure"><span class="hs-identifier hs-type">ExitFailure</span></a></span><span> </span><span id="local-6989586621679048498"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679048498"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; [String] -&gt; Int -&gt; IO ()
forall a. String -&gt; String -&gt; [String] -&gt; Int -&gt; IO a
</span><a href="System.Process.html#processFailedException"><span class="hs-identifier hs-var">processFailedException</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;callCommand&quot;</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048501"><span class="hs-identifier hs-var">cmd</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679048498"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-354"></span><span>
</span><span id="line-355"></span><span id="local-6989586621679048851"><span class="annot"><a href="System.Process.html#processFailedException"><span class="hs-identifier hs-type">processFailedException</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679048851"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-356"></span><span id="processFailedException"><span class="annot"><span class="annottext">processFailedException :: forall a. String -&gt; String -&gt; [String] -&gt; Int -&gt; IO a
</span><a href="System.Process.html#processFailedException"><span class="hs-identifier hs-var hs-var">processFailedException</span></a></span></span><span> </span><span id="local-6989586621679048490"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048490"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span id="local-6989586621679048489"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048489"><span class="hs-identifier hs-var">cmd</span></a></span></span><span> </span><span id="local-6989586621679048488"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048488"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621679048487"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679048487"><span class="hs-identifier hs-var">exit_code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-357"></span><span>      </span><span class="annot"><span class="annottext">IOException -&gt; IO a
forall a. IOException -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOErrorType
-&gt; String -&gt; Maybe Handle -&gt; Maybe String -&gt; IOException
</span><a href="../../base/src/System.IO.Error.html#mkIOError"><span class="hs-identifier hs-var">mkIOError</span></a></span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="../../base/src/GHC.IO.Exception.html#OtherError"><span class="hs-identifier hs-var">OtherError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048490"><span class="hs-identifier hs-var">fun</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;: &quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048489"><span class="hs-identifier hs-var">cmd</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>
</span><span id="line-358"></span><span>                                     </span><span class="annot"><span class="annottext">(String -&gt; String) -&gt; [String] -&gt; String
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">' '</span></span><span class="annot"><span class="annottext">Char -&gt; String -&gt; String
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(String -&gt; String) -&gt; (String -&gt; String) -&gt; String -&gt; String
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048488"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>
</span><span id="line-359"></span><span>                                     </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot; (exit &quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679048487"><span class="hs-identifier hs-var">exit_code</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;)&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-360"></span><span>                                 </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-361"></span><span>
</span><span id="line-362"></span><span>
</span><span id="line-363"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-364"></span><span class="hs-comment">-- Control-C handling on Unix</span><span>
</span><span id="line-365"></span><span>
</span><span id="line-366"></span><span class="hs-comment">-- $ctlc-handling</span><span>
</span><span id="line-367"></span><span class="hs-comment">--</span><span>
</span><span id="line-368"></span><span class="hs-comment">-- When running an interactive console process (such as a shell, console-based</span><span>
</span><span id="line-369"></span><span class="hs-comment">-- text editor or ghci), we typically want that process to be allowed to handle</span><span>
</span><span id="line-370"></span><span class="hs-comment">-- Ctl-C keyboard interrupts how it sees fit. For example, while most programs</span><span>
</span><span id="line-371"></span><span class="hs-comment">-- simply quit on a Ctl-C, some handle it specially. To allow this to happen,</span><span>
</span><span id="line-372"></span><span class="hs-comment">-- use the @'delegate_ctlc' = True@ option in the 'CreateProcess' options.</span><span>
</span><span id="line-373"></span><span class="hs-comment">--</span><span>
</span><span id="line-374"></span><span class="hs-comment">-- The gory details:</span><span>
</span><span id="line-375"></span><span class="hs-comment">--</span><span>
</span><span id="line-376"></span><span class="hs-comment">-- By default Ctl-C will generate a @SIGINT@ signal, causing a 'UserInterrupt'</span><span>
</span><span id="line-377"></span><span class="hs-comment">-- exception to be sent to the main Haskell thread of your program, which if</span><span>
</span><span id="line-378"></span><span class="hs-comment">-- not specially handled will terminate the program. Normally, this is exactly</span><span>
</span><span id="line-379"></span><span class="hs-comment">-- what is wanted: an orderly shutdown of the program in response to Ctl-C.</span><span>
</span><span id="line-380"></span><span class="hs-comment">--</span><span>
</span><span id="line-381"></span><span class="hs-comment">-- Of course when running another interactive program in the console then we</span><span>
</span><span id="line-382"></span><span class="hs-comment">-- want to let that program handle Ctl-C. Under Unix however, Ctl-C sends</span><span>
</span><span id="line-383"></span><span class="hs-comment">-- @SIGINT@ to every process using the console. The standard solution is that</span><span>
</span><span id="line-384"></span><span class="hs-comment">-- while running an interactive program, ignore @SIGINT@ in the parent, and let</span><span>
</span><span id="line-385"></span><span class="hs-comment">-- it be handled in the child process. If that process then terminates due to</span><span>
</span><span id="line-386"></span><span class="hs-comment">-- the @SIGINT@ signal, then at that point treat it as if we had recieved the</span><span>
</span><span id="line-387"></span><span class="hs-comment">-- @SIGINT@ ourselves and begin an orderly shutdown.</span><span>
</span><span id="line-388"></span><span class="hs-comment">--</span><span>
</span><span id="line-389"></span><span class="hs-comment">-- This behaviour is implemented by 'createProcess' (and</span><span>
</span><span id="line-390"></span><span class="hs-comment">-- 'waitForProcess' \/ 'getProcessExitCode') when the @'delegate_ctlc' = True@</span><span>
</span><span id="line-391"></span><span class="hs-comment">-- option is set. In particular, the @SIGINT@ signal will be ignored until</span><span>
</span><span id="line-392"></span><span class="hs-comment">-- 'waitForProcess' returns (or 'getProcessExitCode' returns a non-Nothing</span><span>
</span><span id="line-393"></span><span class="hs-comment">-- result), so it becomes especially important to use 'waitForProcess' for every</span><span>
</span><span id="line-394"></span><span class="hs-comment">-- processes created.</span><span>
</span><span id="line-395"></span><span class="hs-comment">--</span><span>
</span><span id="line-396"></span><span class="hs-comment">-- In addition, in 'delegate_ctlc' mode, 'waitForProcess' and</span><span>
</span><span id="line-397"></span><span class="hs-comment">-- 'getProcessExitCode' will throw a 'UserInterrupt' exception if the process</span><span>
</span><span id="line-398"></span><span class="hs-comment">-- terminated with @'ExitFailure' (-SIGINT)@. Typically you will not want to</span><span>
</span><span id="line-399"></span><span class="hs-comment">-- catch this exception, but let it propagate, giving a normal orderly shutdown.</span><span>
</span><span id="line-400"></span><span class="hs-comment">-- One detail to be aware of is that the 'UserInterrupt' exception is thrown</span><span>
</span><span id="line-401"></span><span class="hs-comment">-- /synchronously/ in the thread that calls 'waitForProcess', whereas normally</span><span>
</span><span id="line-402"></span><span class="hs-comment">-- @SIGINT@ causes the exception to be thrown /asynchronously/ to the main</span><span>
</span><span id="line-403"></span><span class="hs-comment">-- thread.</span><span>
</span><span id="line-404"></span><span class="hs-comment">--</span><span>
</span><span id="line-405"></span><span class="hs-comment">-- For even more detail on this topic, see</span><span>
</span><span id="line-406"></span><span class="hs-comment">-- &lt;http://www.cons.org/cracauer/sigint.html &quot;Proper handling of SIGINT/SIGQUIT&quot;&gt;.</span><span>
</span><span id="line-407"></span><span>
</span><span id="line-408"></span><span class="hs-comment">-- $exec-on-windows</span><span>
</span><span id="line-409"></span><span class="hs-comment">--</span><span>
</span><span id="line-410"></span><span class="hs-comment">-- Note that processes which use the POSIX @exec@ system call (e.g. @gcc@)</span><span>
</span><span id="line-411"></span><span class="hs-comment">-- require special care on Windows. Specifically, the @msvcrt@ C runtime used</span><span>
</span><span id="line-412"></span><span class="hs-comment">-- frequently on Windows emulates @exec@ in a non-POSIX compliant manner, where</span><span>
</span><span id="line-413"></span><span class="hs-comment">-- the caller will be terminated (with exit code 0) and execution will continue</span><span>
</span><span id="line-414"></span><span class="hs-comment">-- in a new process. As a result, on Windows it will appear as though a child</span><span>
</span><span id="line-415"></span><span class="hs-comment">-- process which has called @exec@ has terminated despite the fact that the</span><span>
</span><span id="line-416"></span><span class="hs-comment">-- process would still be running on a POSIX-compliant platform.</span><span>
</span><span id="line-417"></span><span class="hs-comment">--</span><span>
</span><span id="line-418"></span><span class="hs-comment">-- Since many programs do use @exec@, the @process@ library exposes the</span><span>
</span><span id="line-419"></span><span class="hs-comment">-- 'use_process_jobs' flag to make it possible to reliably detect when such a</span><span>
</span><span id="line-420"></span><span class="hs-comment">-- process completes. When this flag is set a 'ProcessHandle' will not be</span><span>
</span><span id="line-421"></span><span class="hs-comment">-- deemed to be \&quot;finished\&quot; until all processes spawned by it have</span><span>
</span><span id="line-422"></span><span class="hs-comment">-- terminated (except those spawned by the child with the</span><span>
</span><span id="line-423"></span><span class="hs-comment">-- @CREATE_BREAKAWAY_FROM_JOB@ @CreateProcess@ flag).</span><span>
</span><span id="line-424"></span><span class="hs-comment">--</span><span>
</span><span id="line-425"></span><span class="hs-comment">-- Note, however, that, because of platform limitations, the exit code returned</span><span>
</span><span id="line-426"></span><span class="hs-comment">-- by @waitForProcess@ and @getProcessExitCode@ cannot not be relied upon when</span><span>
</span><span id="line-427"></span><span class="hs-comment">-- the child uses @exec@, even when 'use_process_jobs' is used. Specifically,</span><span>
</span><span id="line-428"></span><span class="hs-comment">-- these functions will return the exit code of the *original child* (which</span><span>
</span><span id="line-429"></span><span class="hs-comment">-- always exits with code 0, since it called @exec@), not the exit code of the</span><span>
</span><span id="line-430"></span><span class="hs-comment">-- process which carried on with execution after @exec@. This is different from</span><span>
</span><span id="line-431"></span><span class="hs-comment">-- the behavior prescribed by POSIX but is the best approximation that can be</span><span>
</span><span id="line-432"></span><span class="hs-comment">-- realised under the restrictions of the Windows process model.</span><span>
</span><span id="line-433"></span><span>
</span><span id="line-434"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-435"></span><span>
</span><span id="line-436"></span><span class="hs-comment">-- | @readProcess@ forks an external process, reads its standard output</span><span>
</span><span id="line-437"></span><span class="hs-comment">-- strictly, blocking until the process terminates, and returns the output</span><span>
</span><span id="line-438"></span><span class="hs-comment">-- string. The external process inherits the standard error.</span><span>
</span><span id="line-439"></span><span class="hs-comment">--</span><span>
</span><span id="line-440"></span><span class="hs-comment">-- If an asynchronous exception is thrown to the thread executing</span><span>
</span><span id="line-441"></span><span class="hs-comment">-- @readProcess@, the forked process will be terminated and @readProcess@ will</span><span>
</span><span id="line-442"></span><span class="hs-comment">-- wait (block) until the process has been terminated.</span><span>
</span><span id="line-443"></span><span class="hs-comment">--</span><span>
</span><span id="line-444"></span><span class="hs-comment">-- Output is returned strictly, so this is not suitable for launching processes</span><span>
</span><span id="line-445"></span><span class="hs-comment">-- that require interaction over the standard file streams.</span><span>
</span><span id="line-446"></span><span class="hs-comment">--</span><span>
</span><span id="line-447"></span><span class="hs-comment">-- This function throws an 'IOError' if the process 'ExitCode' is</span><span>
</span><span id="line-448"></span><span class="hs-comment">-- anything other than 'ExitSuccess'. If instead you want to get the</span><span>
</span><span id="line-449"></span><span class="hs-comment">-- 'ExitCode' then use 'readProcessWithExitCode'.</span><span>
</span><span id="line-450"></span><span class="hs-comment">--</span><span>
</span><span id="line-451"></span><span class="hs-comment">-- Users of this function should compile with @-threaded@ if they</span><span>
</span><span id="line-452"></span><span class="hs-comment">-- want other Haskell threads to keep running while waiting on</span><span>
</span><span id="line-453"></span><span class="hs-comment">-- the result of readProcess.</span><span>
</span><span id="line-454"></span><span class="hs-comment">--</span><span>
</span><span id="line-455"></span><span class="hs-comment">-- &gt;  &gt; readProcess &quot;date&quot; [] []</span><span>
</span><span id="line-456"></span><span class="hs-comment">-- &gt;  &quot;Thu Feb  7 10:03:39 PST 2008\n&quot;</span><span>
</span><span id="line-457"></span><span class="hs-comment">--</span><span>
</span><span id="line-458"></span><span class="hs-comment">-- The arguments are:</span><span>
</span><span id="line-459"></span><span class="hs-comment">--</span><span>
</span><span id="line-460"></span><span class="hs-comment">-- * The command to run, which must be in the $PATH, or an absolute or relative path</span><span>
</span><span id="line-461"></span><span class="hs-comment">--</span><span>
</span><span id="line-462"></span><span class="hs-comment">-- * A list of separate command line arguments to the program</span><span>
</span><span id="line-463"></span><span class="hs-comment">--</span><span>
</span><span id="line-464"></span><span class="hs-comment">-- * A string to pass on standard input to the forked process.</span><span>
</span><span id="line-465"></span><span class="hs-comment">--</span><span>
</span><span id="line-466"></span><span class="annot"><a href="System.Process.html#readProcess"><span class="hs-identifier hs-type">readProcess</span></a></span><span>
</span><span id="line-467"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>                 </span><span class="hs-comment">-- ^ Filename of the executable (see 'RawCommand' for details)</span><span>
</span><span id="line-468"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span>                 </span><span class="hs-comment">-- ^ any arguments</span><span>
</span><span id="line-469"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>                   </span><span class="hs-comment">-- ^ standard input</span><span>
</span><span id="line-470"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>                </span><span class="hs-comment">-- ^ stdout</span><span>
</span><span id="line-471"></span><span id="readProcess"><span class="annot"><span class="annottext">readProcess :: String -&gt; [String] -&gt; String -&gt; IO String
</span><a href="System.Process.html#readProcess"><span class="hs-identifier hs-var hs-var">readProcess</span></a></span></span><span> </span><span id="local-6989586621679048482"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048482"><span class="hs-identifier hs-var">cmd</span></a></span></span><span> </span><span id="local-6989586621679048481"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048481"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CreateProcess -&gt; String -&gt; IO String
</span><a href="System.Process.html#readCreateProcess"><span class="hs-identifier hs-var">readCreateProcess</span></a></span><span> </span><span class="annot"><span class="annottext">(CreateProcess -&gt; String -&gt; IO String)
-&gt; CreateProcess -&gt; String -&gt; IO String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; CreateProcess
</span><a href="System.Process.html#proc"><span class="hs-identifier hs-var">proc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048482"><span class="hs-identifier hs-var">cmd</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048481"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-472"></span><span>
</span><span id="line-473"></span><span class="hs-comment">-- | @readCreateProcess@ works exactly like 'readProcess' except that it</span><span>
</span><span id="line-474"></span><span class="hs-comment">-- lets you pass 'CreateProcess' giving better flexibility.</span><span>
</span><span id="line-475"></span><span class="hs-comment">--</span><span>
</span><span id="line-476"></span><span class="hs-comment">-- &gt;  &gt; readCreateProcess ((shell &quot;pwd&quot;) { cwd = Just &quot;/etc/&quot; }) &quot;&quot;</span><span>
</span><span id="line-477"></span><span class="hs-comment">-- &gt;  &quot;/etc\n&quot;</span><span>
</span><span id="line-478"></span><span class="hs-comment">--</span><span>
</span><span id="line-479"></span><span class="hs-comment">-- Note that @Handle@s provided for @std_in@ or @std_out@ via the CreateProcess</span><span>
</span><span id="line-480"></span><span class="hs-comment">-- record will be ignored.</span><span>
</span><span id="line-481"></span><span class="hs-comment">--</span><span>
</span><span id="line-482"></span><span class="hs-comment">-- @since 1.2.3.0</span><span>
</span><span id="line-483"></span><span>
</span><span id="line-484"></span><span class="annot"><a href="System.Process.html#readCreateProcess"><span class="hs-identifier hs-type">readCreateProcess</span></a></span><span>
</span><span id="line-485"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier hs-type">CreateProcess</span></a></span><span>
</span><span id="line-486"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>                   </span><span class="hs-comment">-- ^ standard input</span><span>
</span><span id="line-487"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>                </span><span class="hs-comment">-- ^ stdout</span><span>
</span><span id="line-488"></span><span id="readCreateProcess"><span class="annot"><span class="annottext">readCreateProcess :: CreateProcess -&gt; String -&gt; IO String
</span><a href="System.Process.html#readCreateProcess"><span class="hs-identifier hs-var hs-var">readCreateProcess</span></a></span></span><span> </span><span id="local-6989586621679048480"><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048480"><span class="hs-identifier hs-var">cp</span></a></span></span><span> </span><span id="local-6989586621679048479"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048479"><span class="hs-identifier hs-var">input</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-489"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679048478"><span class="annot"><span class="annottext">cp_opts :: CreateProcess
</span><a href="#local-6989586621679048478"><span class="hs-identifier hs-var hs-var">cp_opts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048480"><span class="hs-identifier hs-var">cp</span></a></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-490"></span><span>                    </span><span class="annot"><span class="annottext">std_in :: StdStream
</span><a href="System.Process.Common.html#std_in"><span class="hs-identifier hs-var">std_in</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#CreatePipe"><span class="hs-identifier hs-var">CreatePipe</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-491"></span><span>                    </span><span class="annot"><span class="annottext">std_out :: StdStream
</span><a href="System.Process.Common.html#std_out"><span class="hs-identifier hs-var">std_out</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#CreatePipe"><span class="hs-identifier hs-var">CreatePipe</span></a></span><span>
</span><span id="line-492"></span><span>                  </span><span class="hs-special">}</span><span>
</span><span id="line-493"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679048476"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048476"><span class="hs-identifier hs-var">ex</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048475"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048475"><span class="hs-identifier hs-var">output</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String
-&gt; CreateProcess
-&gt; (Maybe Handle
    -&gt; Maybe Handle
    -&gt; Maybe Handle
    -&gt; ProcessHandle
    -&gt; IO (ExitCode, String))
-&gt; IO (ExitCode, String)
forall a.
String
-&gt; CreateProcess
-&gt; (Maybe Handle
    -&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO a)
-&gt; IO a
</span><a href="System.Process.html#withCreateProcess_"><span class="hs-identifier hs-var">withCreateProcess_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;readCreateProcess&quot;</span></span><span> </span><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048478"><span class="hs-identifier hs-var">cp_opts</span></a></span><span> </span><span class="annot"><span class="annottext">((Maybe Handle
  -&gt; Maybe Handle
  -&gt; Maybe Handle
  -&gt; ProcessHandle
  -&gt; IO (ExitCode, String))
 -&gt; IO (ExitCode, String))
-&gt; (Maybe Handle
    -&gt; Maybe Handle
    -&gt; Maybe Handle
    -&gt; ProcessHandle
    -&gt; IO (ExitCode, String))
-&gt; IO (ExitCode, String)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-494"></span><span>      </span><span class="hs-glyph">\</span><span id="local-6989586621679048474"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048474"><span class="hs-identifier hs-var">mb_inh</span></a></span></span><span> </span><span id="local-6989586621679048473"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048473"><span class="hs-identifier hs-var">mb_outh</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679048472"><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048472"><span class="hs-identifier hs-var">ph</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-495"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048474"><span class="hs-identifier hs-var">mb_inh</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048473"><span class="hs-identifier hs-var">mb_outh</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-496"></span><span>          </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679048471"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048471"><span class="hs-identifier hs-var">inh</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679048470"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048470"><span class="hs-identifier hs-var">outh</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-497"></span><span>
</span><span id="line-498"></span><span>            </span><span class="hs-comment">-- fork off a thread to start consuming the output</span><span>
</span><span id="line-499"></span><span>            </span><span id="local-6989586621679048469"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048469"><span class="hs-identifier hs-var">output</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO String
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hGetContents"><span class="hs-identifier hs-var">hGetContents</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048470"><span class="hs-identifier hs-var">outh</span></a></span><span>
</span><span id="line-500"></span><span>            </span><span class="annot"><span class="annottext">IO () -&gt; (IO () -&gt; IO ()) -&gt; IO ()
forall a. IO () -&gt; (IO () -&gt; IO a) -&gt; IO a
</span><a href="System.Process.html#withForkWait"><span class="hs-identifier hs-var">withForkWait</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">() -&gt; IO ()
forall a. a -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#evaluate"><span class="hs-identifier hs-var">C.evaluate</span></a></span><span> </span><span class="annot"><span class="annottext">(() -&gt; IO ()) -&gt; () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ()
forall a. NFData a =&gt; a -&gt; ()
</span><a href="../../deepseq/src/Control.DeepSeq.html#rnf"><span class="hs-identifier hs-var">rnf</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048469"><span class="hs-identifier hs-var">output</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((IO () -&gt; IO ()) -&gt; IO ()) -&gt; (IO () -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679048465"><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679048465"><span class="hs-identifier hs-var">waitOut</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-501"></span><span>
</span><span id="line-502"></span><span>              </span><span class="hs-comment">-- now write any input</span><span>
</span><span id="line-503"></span><span>              </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048479"><span class="hs-identifier hs-var">input</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-504"></span><span>                </span><span class="annot"><span class="annottext">IO () -&gt; IO ()
</span><a href="System.Process.html#ignoreSigPipe"><span class="hs-identifier hs-var">ignoreSigPipe</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; String -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutStr"><span class="hs-identifier hs-var">hPutStr</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048471"><span class="hs-identifier hs-var">inh</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048479"><span class="hs-identifier hs-var">input</span></a></span><span>
</span><span id="line-505"></span><span>              </span><span class="hs-comment">-- hClose performs implicit hFlush, and thus may trigger a SIGPIPE</span><span>
</span><span id="line-506"></span><span>              </span><span class="annot"><span class="annottext">IO () -&gt; IO ()
</span><a href="System.Process.html#ignoreSigPipe"><span class="hs-identifier hs-var">ignoreSigPipe</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048471"><span class="hs-identifier hs-var">inh</span></a></span><span>
</span><span id="line-507"></span><span>
</span><span id="line-508"></span><span>              </span><span class="hs-comment">-- wait on the output</span><span>
</span><span id="line-509"></span><span>              </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679048465"><span class="hs-identifier hs-var">waitOut</span></a></span><span>
</span><span id="line-510"></span><span>              </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048470"><span class="hs-identifier hs-var">outh</span></a></span><span>
</span><span id="line-511"></span><span>
</span><span id="line-512"></span><span>            </span><span class="hs-comment">-- wait on the process</span><span>
</span><span id="line-513"></span><span>            </span><span id="local-6989586621679048461"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048461"><span class="hs-identifier hs-var">ex</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ProcessHandle -&gt; IO ExitCode
</span><a href="System.Process.html#waitForProcess"><span class="hs-identifier hs-var">waitForProcess</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048472"><span class="hs-identifier hs-var">ph</span></a></span><span>
</span><span id="line-514"></span><span>            </span><span class="annot"><span class="annottext">(ExitCode, String) -&gt; IO (ExitCode, String)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048461"><span class="hs-identifier hs-var">ex</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048469"><span class="hs-identifier hs-var">output</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-515"></span><span>
</span><span id="line-516"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (ExitCode, String)
forall a. HasCallStack =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;readCreateProcess: Failed to get a stdin handle.&quot;</span></span><span>
</span><span id="line-517"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (ExitCode, String)
forall a. HasCallStack =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;readCreateProcess: Failed to get a stdout handle.&quot;</span></span><span>
</span><span id="line-518"></span><span>
</span><span id="line-519"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048476"><span class="hs-identifier hs-var">ex</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-520"></span><span>     </span><span class="annot"><span class="annottext">ExitCode
</span><a href="../../base/src/GHC.IO.Exception.html#ExitSuccess"><span class="hs-identifier hs-var">ExitSuccess</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO String
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048475"><span class="hs-identifier hs-var">output</span></a></span><span>
</span><span id="line-521"></span><span>     </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ExitFailure"><span class="hs-identifier hs-type">ExitFailure</span></a></span><span> </span><span id="local-6989586621679048459"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679048459"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; [String] -&gt; Int -&gt; IO String
forall a. String -&gt; String -&gt; [String] -&gt; Int -&gt; IO a
</span><a href="System.Process.html#processFailedException"><span class="hs-identifier hs-var">processFailedException</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;readCreateProcess&quot;</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048458"><span class="hs-identifier hs-var">cmd</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048457"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679048459"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-522"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-523"></span><span>    </span><span id="local-6989586621679048458"><span class="annot"><span class="annottext">cmd :: String
</span><a href="#local-6989586621679048458"><span class="hs-identifier hs-var hs-var">cmd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048480"><span class="hs-identifier hs-var">cp</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-524"></span><span>            </span><span class="annot"><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier hs-type">CreateProcess</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cmdspec :: CreateProcess -&gt; CmdSpec
</span><a href="System.Process.Common.html#cmdspec"><span class="hs-identifier hs-var">cmdspec</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="System.Process.Common.html#ShellCommand"><span class="hs-identifier hs-type">ShellCommand</span></a></span><span> </span><span id="local-6989586621679048456"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048456"><span class="hs-identifier hs-var">sc</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048456"><span class="hs-identifier hs-var">sc</span></a></span><span>
</span><span id="line-525"></span><span>            </span><span class="annot"><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier hs-type">CreateProcess</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cmdspec :: CreateProcess -&gt; CmdSpec
</span><a href="System.Process.Common.html#cmdspec"><span class="hs-identifier hs-var">cmdspec</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="System.Process.Common.html#RawCommand"><span class="hs-identifier hs-type">RawCommand</span></a></span><span> </span><span id="local-6989586621679048455"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048455"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span class="annot"><span class="annottext">[String]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048455"><span class="hs-identifier hs-var">fp</span></a></span><span>
</span><span id="line-526"></span><span>    </span><span id="local-6989586621679048457"><span class="annot"><span class="annottext">args :: [String]
</span><a href="#local-6989586621679048457"><span class="hs-identifier hs-var hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048480"><span class="hs-identifier hs-var">cp</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-527"></span><span>             </span><span class="annot"><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier hs-type">CreateProcess</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cmdspec :: CreateProcess -&gt; CmdSpec
</span><a href="System.Process.Common.html#cmdspec"><span class="hs-identifier hs-var">cmdspec</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="System.Process.Common.html#ShellCommand"><span class="hs-identifier hs-type">ShellCommand</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-528"></span><span>             </span><span class="annot"><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier hs-type">CreateProcess</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cmdspec :: CreateProcess -&gt; CmdSpec
</span><a href="System.Process.Common.html#cmdspec"><span class="hs-identifier hs-var">cmdspec</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="System.Process.Common.html#RawCommand"><span class="hs-identifier hs-type">RawCommand</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679048454"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048454"><span class="hs-identifier hs-var">args'</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048454"><span class="hs-identifier hs-var">args'</span></a></span><span>
</span><span id="line-529"></span><span>
</span><span id="line-530"></span><span>
</span><span id="line-531"></span><span class="hs-comment">-- | @readProcessWithExitCode@ is like 'readProcess' but with two differences:</span><span>
</span><span id="line-532"></span><span class="hs-comment">--</span><span>
</span><span id="line-533"></span><span class="hs-comment">--  * it returns the 'ExitCode' of the process, and does not throw any</span><span>
</span><span id="line-534"></span><span class="hs-comment">--    exception if the code is not 'ExitSuccess'.</span><span>
</span><span id="line-535"></span><span class="hs-comment">--</span><span>
</span><span id="line-536"></span><span class="hs-comment">--  * it reads and returns the output from process' standard error handle,</span><span>
</span><span id="line-537"></span><span class="hs-comment">--    rather than the process inheriting the standard error handle.</span><span>
</span><span id="line-538"></span><span class="hs-comment">--</span><span>
</span><span id="line-539"></span><span class="hs-comment">-- On Unix systems, see 'waitForProcess' for the meaning of exit codes</span><span>
</span><span id="line-540"></span><span class="hs-comment">-- when the process died as the result of a signal.</span><span>
</span><span id="line-541"></span><span class="hs-comment">--</span><span>
</span><span id="line-542"></span><span class="annot"><a href="System.Process.html#readProcessWithExitCode"><span class="hs-identifier hs-type">readProcessWithExitCode</span></a></span><span>
</span><span id="line-543"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>                 </span><span class="hs-comment">-- ^ Filename of the executable (see 'RawCommand' for details)</span><span>
</span><span id="line-544"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span>                 </span><span class="hs-comment">-- ^ any arguments</span><span>
</span><span id="line-545"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>                   </span><span class="hs-comment">-- ^ standard input</span><span>
</span><span id="line-546"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ExitCode"><span class="hs-identifier hs-type">ExitCode</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- ^ exitcode, stdout, stderr</span><span>
</span><span id="line-547"></span><span id="readProcessWithExitCode"><span class="annot"><span class="annottext">readProcessWithExitCode :: String -&gt; [String] -&gt; String -&gt; IO (ExitCode, String, String)
</span><a href="System.Process.html#readProcessWithExitCode"><span class="hs-identifier hs-var hs-var">readProcessWithExitCode</span></a></span></span><span> </span><span id="local-6989586621679048453"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048453"><span class="hs-identifier hs-var">cmd</span></a></span></span><span> </span><span id="local-6989586621679048452"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048452"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-548"></span><span>    </span><span class="annot"><span class="annottext">CreateProcess -&gt; String -&gt; IO (ExitCode, String, String)
</span><a href="System.Process.html#readCreateProcessWithExitCode"><span class="hs-identifier hs-var">readCreateProcessWithExitCode</span></a></span><span> </span><span class="annot"><span class="annottext">(CreateProcess -&gt; String -&gt; IO (ExitCode, String, String))
-&gt; CreateProcess -&gt; String -&gt; IO (ExitCode, String, String)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; CreateProcess
</span><a href="System.Process.html#proc"><span class="hs-identifier hs-var">proc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048453"><span class="hs-identifier hs-var">cmd</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048452"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-549"></span><span>
</span><span id="line-550"></span><span class="hs-comment">-- | @readCreateProcessWithExitCode@ works exactly like 'readProcessWithExitCode' except that it</span><span>
</span><span id="line-551"></span><span class="hs-comment">-- lets you pass 'CreateProcess' giving better flexibility.</span><span>
</span><span id="line-552"></span><span class="hs-comment">--</span><span>
</span><span id="line-553"></span><span class="hs-comment">-- Note that @Handle@s provided for @std_in@, @std_out@, or @std_err@ via the CreateProcess</span><span>
</span><span id="line-554"></span><span class="hs-comment">-- record will be ignored.</span><span>
</span><span id="line-555"></span><span class="hs-comment">--</span><span>
</span><span id="line-556"></span><span class="hs-comment">-- @since 1.2.3.0</span><span>
</span><span id="line-557"></span><span class="annot"><a href="System.Process.html#readCreateProcessWithExitCode"><span class="hs-identifier hs-type">readCreateProcessWithExitCode</span></a></span><span>
</span><span id="line-558"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier hs-type">CreateProcess</span></a></span><span>
</span><span id="line-559"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>                      </span><span class="hs-comment">-- ^ standard input</span><span>
</span><span id="line-560"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ExitCode"><span class="hs-identifier hs-type">ExitCode</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- ^ exitcode, stdout, stderr</span><span>
</span><span id="line-561"></span><span id="readCreateProcessWithExitCode"><span class="annot"><span class="annottext">readCreateProcessWithExitCode :: CreateProcess -&gt; String -&gt; IO (ExitCode, String, String)
</span><a href="System.Process.html#readCreateProcessWithExitCode"><span class="hs-identifier hs-var hs-var">readCreateProcessWithExitCode</span></a></span></span><span> </span><span id="local-6989586621679048451"><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048451"><span class="hs-identifier hs-var">cp</span></a></span></span><span> </span><span id="local-6989586621679048450"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048450"><span class="hs-identifier hs-var">input</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-562"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679048449"><span class="annot"><span class="annottext">cp_opts :: CreateProcess
</span><a href="#local-6989586621679048449"><span class="hs-identifier hs-var hs-var">cp_opts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048451"><span class="hs-identifier hs-var">cp</span></a></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-563"></span><span>                    </span><span class="annot"><span class="annottext">std_in :: StdStream
</span><a href="System.Process.Common.html#std_in"><span class="hs-identifier hs-var">std_in</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#CreatePipe"><span class="hs-identifier hs-var">CreatePipe</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-564"></span><span>                    </span><span class="annot"><span class="annottext">std_out :: StdStream
</span><a href="System.Process.Common.html#std_out"><span class="hs-identifier hs-var">std_out</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#CreatePipe"><span class="hs-identifier hs-var">CreatePipe</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-565"></span><span>                    </span><span class="annot"><span class="annottext">std_err :: StdStream
</span><a href="System.Process.Common.html#std_err"><span class="hs-identifier hs-var">std_err</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#CreatePipe"><span class="hs-identifier hs-var">CreatePipe</span></a></span><span>
</span><span id="line-566"></span><span>                  </span><span class="hs-special">}</span><span>
</span><span id="line-567"></span><span>    </span><span class="annot"><span class="annottext">String
-&gt; CreateProcess
-&gt; (Maybe Handle
    -&gt; Maybe Handle
    -&gt; Maybe Handle
    -&gt; ProcessHandle
    -&gt; IO (ExitCode, String, String))
-&gt; IO (ExitCode, String, String)
forall a.
String
-&gt; CreateProcess
-&gt; (Maybe Handle
    -&gt; Maybe Handle -&gt; Maybe Handle -&gt; ProcessHandle -&gt; IO a)
-&gt; IO a
</span><a href="System.Process.html#withCreateProcess_"><span class="hs-identifier hs-var">withCreateProcess_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;readCreateProcessWithExitCode&quot;</span></span><span> </span><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048449"><span class="hs-identifier hs-var">cp_opts</span></a></span><span> </span><span class="annot"><span class="annottext">((Maybe Handle
  -&gt; Maybe Handle
  -&gt; Maybe Handle
  -&gt; ProcessHandle
  -&gt; IO (ExitCode, String, String))
 -&gt; IO (ExitCode, String, String))
-&gt; (Maybe Handle
    -&gt; Maybe Handle
    -&gt; Maybe Handle
    -&gt; ProcessHandle
    -&gt; IO (ExitCode, String, String))
-&gt; IO (ExitCode, String, String)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-568"></span><span>      </span><span class="hs-glyph">\</span><span id="local-6989586621679048448"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048448"><span class="hs-identifier hs-var">mb_inh</span></a></span></span><span> </span><span id="local-6989586621679048447"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048447"><span class="hs-identifier hs-var">mb_outh</span></a></span></span><span> </span><span id="local-6989586621679048446"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048446"><span class="hs-identifier hs-var">mb_errh</span></a></span></span><span> </span><span id="local-6989586621679048445"><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048445"><span class="hs-identifier hs-var">ph</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-569"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048448"><span class="hs-identifier hs-var">mb_inh</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048447"><span class="hs-identifier hs-var">mb_outh</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048446"><span class="hs-identifier hs-var">mb_errh</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-570"></span><span>          </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679048444"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048444"><span class="hs-identifier hs-var">inh</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679048443"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048443"><span class="hs-identifier hs-var">outh</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679048442"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048442"><span class="hs-identifier hs-var">errh</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-571"></span><span>
</span><span id="line-572"></span><span>            </span><span id="local-6989586621679048441"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048441"><span class="hs-identifier hs-var">out</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO String
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hGetContents"><span class="hs-identifier hs-var">hGetContents</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048443"><span class="hs-identifier hs-var">outh</span></a></span><span>
</span><span id="line-573"></span><span>            </span><span id="local-6989586621679048440"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048440"><span class="hs-identifier hs-var">err</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO String
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hGetContents"><span class="hs-identifier hs-var">hGetContents</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048442"><span class="hs-identifier hs-var">errh</span></a></span><span>
</span><span id="line-574"></span><span>
</span><span id="line-575"></span><span>            </span><span class="hs-comment">-- fork off threads to start consuming stdout &amp; stderr</span><span>
</span><span id="line-576"></span><span>            </span><span class="annot"><span class="annottext">IO () -&gt; (IO () -&gt; IO ()) -&gt; IO ()
forall a. IO () -&gt; (IO () -&gt; IO a) -&gt; IO a
</span><a href="System.Process.html#withForkWait"><span class="hs-identifier hs-var">withForkWait</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">() -&gt; IO ()
forall a. a -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#evaluate"><span class="hs-identifier hs-var">C.evaluate</span></a></span><span> </span><span class="annot"><span class="annottext">(() -&gt; IO ()) -&gt; () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ()
forall a. NFData a =&gt; a -&gt; ()
</span><a href="../../deepseq/src/Control.DeepSeq.html#rnf"><span class="hs-identifier hs-var">rnf</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048441"><span class="hs-identifier hs-var">out</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((IO () -&gt; IO ()) -&gt; IO ()) -&gt; (IO () -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679048439"><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679048439"><span class="hs-identifier hs-var">waitOut</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-577"></span><span>             </span><span class="annot"><span class="annottext">IO () -&gt; (IO () -&gt; IO ()) -&gt; IO ()
forall a. IO () -&gt; (IO () -&gt; IO a) -&gt; IO a
</span><a href="System.Process.html#withForkWait"><span class="hs-identifier hs-var">withForkWait</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">() -&gt; IO ()
forall a. a -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#evaluate"><span class="hs-identifier hs-var">C.evaluate</span></a></span><span> </span><span class="annot"><span class="annottext">(() -&gt; IO ()) -&gt; () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ()
forall a. NFData a =&gt; a -&gt; ()
</span><a href="../../deepseq/src/Control.DeepSeq.html#rnf"><span class="hs-identifier hs-var">rnf</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048440"><span class="hs-identifier hs-var">err</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((IO () -&gt; IO ()) -&gt; IO ()) -&gt; (IO () -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679048438"><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679048438"><span class="hs-identifier hs-var">waitErr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-578"></span><span>
</span><span id="line-579"></span><span>              </span><span class="hs-comment">-- now write any input</span><span>
</span><span id="line-580"></span><span>              </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048450"><span class="hs-identifier hs-var">input</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-581"></span><span>                </span><span class="annot"><span class="annottext">IO () -&gt; IO ()
</span><a href="System.Process.html#ignoreSigPipe"><span class="hs-identifier hs-var">ignoreSigPipe</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; String -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutStr"><span class="hs-identifier hs-var">hPutStr</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048444"><span class="hs-identifier hs-var">inh</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048450"><span class="hs-identifier hs-var">input</span></a></span><span>
</span><span id="line-582"></span><span>              </span><span class="hs-comment">-- hClose performs implicit hFlush, and thus may trigger a SIGPIPE</span><span>
</span><span id="line-583"></span><span>              </span><span class="annot"><span class="annottext">IO () -&gt; IO ()
</span><a href="System.Process.html#ignoreSigPipe"><span class="hs-identifier hs-var">ignoreSigPipe</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048444"><span class="hs-identifier hs-var">inh</span></a></span><span>
</span><span id="line-584"></span><span>
</span><span id="line-585"></span><span>              </span><span class="hs-comment">-- wait on the output</span><span>
</span><span id="line-586"></span><span>              </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679048439"><span class="hs-identifier hs-var">waitOut</span></a></span><span>
</span><span id="line-587"></span><span>              </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679048438"><span class="hs-identifier hs-var">waitErr</span></a></span><span>
</span><span id="line-588"></span><span>
</span><span id="line-589"></span><span>              </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048443"><span class="hs-identifier hs-var">outh</span></a></span><span>
</span><span id="line-590"></span><span>              </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048442"><span class="hs-identifier hs-var">errh</span></a></span><span>
</span><span id="line-591"></span><span>
</span><span id="line-592"></span><span>            </span><span class="hs-comment">-- wait on the process</span><span>
</span><span id="line-593"></span><span>            </span><span id="local-6989586621679048437"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048437"><span class="hs-identifier hs-var">ex</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ProcessHandle -&gt; IO ExitCode
</span><a href="System.Process.html#waitForProcess"><span class="hs-identifier hs-var">waitForProcess</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048445"><span class="hs-identifier hs-var">ph</span></a></span><span>
</span><span id="line-594"></span><span>            </span><span class="annot"><span class="annottext">(ExitCode, String, String) -&gt; IO (ExitCode, String, String)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048437"><span class="hs-identifier hs-var">ex</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048441"><span class="hs-identifier hs-var">out</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048440"><span class="hs-identifier hs-var">err</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-595"></span><span>
</span><span id="line-596"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (ExitCode, String, String)
forall a. HasCallStack =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;readCreateProcessWithExitCode: Failed to get a stdin handle.&quot;</span></span><span>
</span><span id="line-597"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (ExitCode, String, String)
forall a. HasCallStack =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;readCreateProcessWithExitCode: Failed to get a stdout handle.&quot;</span></span><span>
</span><span id="line-598"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (ExitCode, String, String)
forall a. HasCallStack =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;readCreateProcessWithExitCode: Failed to get a stderr handle.&quot;</span></span><span>
</span><span id="line-599"></span><span>
</span><span id="line-600"></span><span class="hs-comment">-- | Fork a thread while doing something else, but kill it if there's an</span><span>
</span><span id="line-601"></span><span class="hs-comment">-- exception.</span><span>
</span><span id="line-602"></span><span class="hs-comment">--</span><span>
</span><span id="line-603"></span><span class="hs-comment">-- This is important in the cases above because we want to kill the thread</span><span>
</span><span id="line-604"></span><span class="hs-comment">-- that is holding the Handle lock, because when we clean up the process we</span><span>
</span><span id="line-605"></span><span class="hs-comment">-- try to close that handle, which could otherwise deadlock.</span><span>
</span><span id="line-606"></span><span class="hs-comment">--</span><span>
</span><span id="line-607"></span><span id="local-6989586621679048841"><span class="annot"><a href="System.Process.html#withForkWait"><span class="hs-identifier hs-type">withForkWait</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>  </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679048841"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679048841"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-608"></span><span id="withForkWait"><span class="annot"><span class="annottext">withForkWait :: forall a. IO () -&gt; (IO () -&gt; IO a) -&gt; IO a
</span><a href="System.Process.html#withForkWait"><span class="hs-identifier hs-var hs-var">withForkWait</span></a></span></span><span> </span><span id="local-6989586621679048431"><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679048431"><span class="hs-identifier hs-var">async</span></a></span></span><span> </span><span id="local-6989586621679048430"><span class="annot"><span class="annottext">IO () -&gt; IO a
</span><a href="#local-6989586621679048430"><span class="hs-identifier hs-var">body</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-609"></span><span>  </span><span id="local-6989586621679048429"><span class="annot"><span class="annottext">MVar (Either SomeException ())
</span><a href="#local-6989586621679048429"><span class="hs-identifier hs-var">waitVar</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO (MVar (Either SomeException ()))
forall a. IO (MVar a)
</span><a href="../../base/src/GHC.MVar.html#newEmptyMVar"><span class="hs-identifier hs-var">newEmptyMVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Exception.Type.html#SomeException"><span class="hs-identifier hs-type">SomeException</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-610"></span><span>  </span><span class="annot"><span class="annottext">((forall a. IO a -&gt; IO a) -&gt; IO a) -&gt; IO a
forall b. ((forall a. IO a -&gt; IO a) -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.IO.html#mask"><span class="hs-identifier hs-var">mask</span></a></span><span> </span><span class="annot"><span class="annottext">(((forall a. IO a -&gt; IO a) -&gt; IO a) -&gt; IO a)
-&gt; ((forall a. IO a -&gt; IO a) -&gt; IO a) -&gt; IO a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679048427"><span class="annot"><span class="annottext">forall a. IO a -&gt; IO a
</span><a href="#local-6989586621679048427"><span class="hs-identifier hs-var">restore</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-611"></span><span>    </span><span id="local-6989586621679048426"><span class="annot"><span class="annottext">ThreadId
</span><a href="#local-6989586621679048426"><span class="hs-identifier hs-var">tid</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO ThreadId
</span><a href="../../base/src/GHC.Conc.Sync.html#forkIO"><span class="hs-identifier hs-var">forkIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ThreadId) -&gt; IO () -&gt; IO ThreadId
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO (Either SomeException ())
forall e a. Exception e =&gt; IO a -&gt; IO (Either e a)
</span><a href="../../base/src/Control.Exception.Base.html#try"><span class="hs-identifier hs-var">try</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO () -&gt; IO ()
forall a. IO a -&gt; IO a
</span><a href="#local-6989586621679048427"><span class="hs-identifier hs-var">restore</span></a></span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679048431"><span class="hs-identifier hs-var">async</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO (Either SomeException ())
-&gt; (Either SomeException () -&gt; IO ()) -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">MVar (Either SomeException ()) -&gt; Either SomeException () -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="../../base/src/GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar (Either SomeException ())
</span><a href="#local-6989586621679048429"><span class="hs-identifier hs-var">waitVar</span></a></span><span>
</span><span id="line-612"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679048421"><span class="annot"><span class="annottext">wait :: IO ()
</span><a href="#local-6989586621679048421"><span class="hs-identifier hs-var hs-var">wait</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MVar (Either SomeException ()) -&gt; IO (Either SomeException ())
forall a. MVar a -&gt; IO a
</span><a href="../../base/src/GHC.MVar.html#takeMVar"><span class="hs-identifier hs-var">takeMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar (Either SomeException ())
</span><a href="#local-6989586621679048429"><span class="hs-identifier hs-var">waitVar</span></a></span><span> </span><span class="annot"><span class="annottext">IO (Either SomeException ())
-&gt; (Either SomeException () -&gt; IO ()) -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">(SomeException -&gt; IO ())
-&gt; (() -&gt; IO ()) -&gt; Either SomeException () -&gt; IO ()
forall a c b. (a -&gt; c) -&gt; (b -&gt; c) -&gt; Either a b -&gt; c
</span><a href="../../base/src/Data.Either.html#either"><span class="hs-identifier hs-var">either</span></a></span><span> </span><span class="annot"><span class="annottext">SomeException -&gt; IO ()
forall e a. Exception e =&gt; e -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#throwIO"><span class="hs-identifier hs-var">throwIO</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span>
</span><span id="line-613"></span><span>    </span><span class="annot"><span class="annottext">IO a -&gt; IO a
forall a. IO a -&gt; IO a
</span><a href="#local-6989586621679048427"><span class="hs-identifier hs-var">restore</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO () -&gt; IO a
</span><a href="#local-6989586621679048430"><span class="hs-identifier hs-var">body</span></a></span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679048421"><span class="hs-identifier hs-var">wait</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO a -&gt; IO () -&gt; IO a
forall a b. IO a -&gt; IO b -&gt; IO a
</span><a href="../../base/src/Control.Exception.Base.html#onException"><span class="hs-operator hs-var">`C.onException`</span></a></span><span> </span><span class="annot"><span class="annottext">ThreadId -&gt; IO ()
</span><a href="../../base/src/GHC.Conc.Sync.html#killThread"><span class="hs-identifier hs-var">killThread</span></a></span><span> </span><span class="annot"><span class="annottext">ThreadId
</span><a href="#local-6989586621679048426"><span class="hs-identifier hs-var">tid</span></a></span><span>
</span><span id="line-614"></span><span>
</span><span id="line-615"></span><span class="annot"><a href="System.Process.html#ignoreSigPipe"><span class="hs-identifier hs-type">ignoreSigPipe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-616"></span><span id="ignoreSigPipe"><span class="annot"><span class="annottext">ignoreSigPipe :: IO () -&gt; IO ()
</span><a href="System.Process.html#ignoreSigPipe"><span class="hs-identifier hs-var hs-var">ignoreSigPipe</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IOException -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall e a. Exception e =&gt; (e -&gt; IO a) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/Control.Exception.Base.html#handle"><span class="hs-identifier hs-var">C.handle</span></a></span><span> </span><span class="annot"><span class="annottext">((IOException -&gt; IO ()) -&gt; IO () -&gt; IO ())
-&gt; (IOException -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679048415"><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679048415"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679048415"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-617"></span><span>                                   </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#IOError"><span class="hs-identifier hs-type">IOError</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ioe_type :: IOException -&gt; IOErrorType
</span><a href="../../base/src/GHC.IO.Exception.html#ioe_type"><span class="hs-identifier hs-var">ioe_type</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="../../base/src/GHC.IO.Exception.html#ResourceVanished"><span class="hs-identifier hs-var">ResourceVanished</span></a></span><span>
</span><span id="line-618"></span><span>                                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ioe_errno :: IOException -&gt; Maybe CInt
</span><a href="../../base/src/GHC.IO.Exception.html#ioe_errno"><span class="hs-identifier hs-var">ioe_errno</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679048410"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679048410"><span class="hs-identifier hs-var">ioe</span></a></span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-619"></span><span>                                     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Errno
</span><a href="../../base/src/Foreign.C.Error.html#Errno"><span class="hs-identifier hs-var">Errno</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679048410"><span class="hs-identifier hs-var">ioe</span></a></span><span> </span><span class="annot"><span class="annottext">Errno -&gt; Errno -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Errno
</span><a href="../../base/src/Foreign.C.Error.html#ePIPE"><span class="hs-identifier hs-var">ePIPE</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-620"></span><span>                                   </span><span class="annot"><span class="annottext">IOException
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; IO ()
forall e a. Exception e =&gt; e -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#throwIO"><span class="hs-identifier hs-var">throwIO</span></a></span><span> </span><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679048415"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-621"></span><span>
</span><span id="line-622"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-623"></span><span class="hs-comment">-- showCommandForUser</span><span>
</span><span id="line-624"></span><span>
</span><span id="line-625"></span><span class="hs-comment">-- | Given a program @/p/@ and arguments @/args/@,</span><span>
</span><span id="line-626"></span><span class="hs-comment">--   @showCommandForUser /p/ /args/@ returns a string suitable for pasting</span><span>
</span><span id="line-627"></span><span class="hs-comment">--   into @\/bin\/sh@ (on Unix systems) or @CMD.EXE@ (on Windows).</span><span>
</span><span id="line-628"></span><span class="annot"><a href="System.Process.html#showCommandForUser"><span class="hs-identifier hs-type">showCommandForUser</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-629"></span><span id="showCommandForUser"><span class="annot"><span class="annottext">showCommandForUser :: String -&gt; [String] -&gt; String
</span><a href="System.Process.html#showCommandForUser"><span class="hs-identifier hs-var hs-var">showCommandForUser</span></a></span></span><span> </span><span id="local-6989586621679048407"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048407"><span class="hs-identifier hs-var">cmd</span></a></span></span><span> </span><span id="local-6989586621679048406"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048406"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[String] -&gt; String
</span><a href="../../base/src/Data.OldList.html#unwords"><span class="hs-identifier hs-var">unwords</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(String -&gt; String) -&gt; [String] -&gt; [String]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String
</span><a href="System.Process.Internals.html#translate"><span class="hs-identifier hs-var">translate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048407"><span class="hs-identifier hs-var">cmd</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; [String]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048406"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-630"></span><span>
</span><span id="line-631"></span><span>
</span><span id="line-632"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-633"></span><span class="hs-comment">-- getPid</span><span>
</span><span id="line-634"></span><span>
</span><span id="line-635"></span><span class="hs-comment">-- | Returns the PID (process ID) of a subprocess.</span><span>
</span><span id="line-636"></span><span class="hs-comment">--</span><span>
</span><span id="line-637"></span><span class="hs-comment">-- 'Nothing' is returned if the handle was already closed. Otherwise a</span><span>
</span><span id="line-638"></span><span class="hs-comment">-- PID is returned that remains valid as long as the handle is open.</span><span>
</span><span id="line-639"></span><span class="hs-comment">-- The operating system may reuse the PID as soon as the last handle to</span><span>
</span><span id="line-640"></span><span class="hs-comment">-- the process is closed.</span><span>
</span><span id="line-641"></span><span class="hs-comment">--</span><span>
</span><span id="line-642"></span><span class="hs-comment">-- @since 1.6.3.0</span><span>
</span><span id="line-643"></span><span class="annot"><a href="System.Process.html#getPid"><span class="hs-identifier hs-type">getPid</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="System.Process.html#Pid"><span class="hs-identifier hs-type">Pid</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-644"></span><span id="getPid"><span class="annot"><span class="annottext">getPid :: ProcessHandle -&gt; IO (Maybe Pid)
</span><a href="System.Process.html#getPid"><span class="hs-identifier hs-var hs-var">getPid</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span> </span><span id="local-6989586621679048403"><span class="annot"><span class="annottext">MVar ProcessHandle__
</span><a href="#local-6989586621679048403"><span class="hs-identifier hs-var">mh</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">MVar ()
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-645"></span><span>  </span><span id="local-6989586621679048402"><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048402"><span class="hs-identifier hs-var">p_</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MVar ProcessHandle__ -&gt; IO ProcessHandle__
forall a. MVar a -&gt; IO a
</span><a href="../../base/src/GHC.MVar.html#readMVar"><span class="hs-identifier hs-var">readMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar ProcessHandle__
</span><a href="#local-6989586621679048403"><span class="hs-identifier hs-var">mh</span></a></span><span>
</span><span id="line-646"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048402"><span class="hs-identifier hs-var">p_</span></a></span><span> </span><span class="hs-keyword">of</span><span class="hs-cpp">
#ifdef WINDOWS
</span><span>    </span><span class="annot"><a href="System.Process.Common.html#OpenHandle"><span class="hs-identifier hs-type">OpenHandle</span></a></span><span> </span><span id="local-6989586621679048399"><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048399"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-649"></span><span>      </span><span id="local-6989586621679048398"><span class="annot"><span class="annottext">Pid
</span><a href="#local-6989586621679048398"><span class="hs-identifier hs-var">pid</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">PHANDLE -&gt; IO Pid
</span><a href="../../Win32/src/System.Win32.Process.html#getProcessId"><span class="hs-identifier hs-var">getProcessId</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048399"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-650"></span><span>      </span><span class="annot"><span class="annottext">Maybe Pid -&gt; IO (Maybe Pid)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Pid -&gt; IO (Maybe Pid)) -&gt; Maybe Pid -&gt; IO (Maybe Pid)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Pid -&gt; Maybe Pid
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Pid
</span><a href="#local-6989586621679048398"><span class="hs-identifier hs-var">pid</span></a></span><span class="hs-cpp">
#else
</span><span>    </span><span class="hs-identifier">OpenHandle</span><span> </span><span class="hs-identifier">pid</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">Just</span><span> </span><span class="hs-identifier">pid</span><span class="hs-cpp">
#endif
</span><span>    </span><span class="annot"><span class="annottext">ProcessHandle__
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Pid -&gt; IO (Maybe Pid)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Pid
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-655"></span><span>
</span><span id="line-656"></span><span>
</span><span id="line-657"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-658"></span><span class="hs-comment">-- getCurrentPid</span><span>
</span><span id="line-659"></span><span>
</span><span id="line-660"></span><span class="hs-comment">-- | Returns the PID (process ID) of the current process. On POSIX systems,</span><span>
</span><span id="line-661"></span><span class="hs-comment">-- this calls 'getProcessID' from &quot;System.Posix.Process&quot; in the @unix@ package.</span><span>
</span><span id="line-662"></span><span class="hs-comment">-- On Windows, this calls 'getCurrentProcessId' from &quot;System.Win32.Process&quot; in</span><span>
</span><span id="line-663"></span><span class="hs-comment">-- the @Win32@ package.</span><span>
</span><span id="line-664"></span><span class="hs-comment">--</span><span>
</span><span id="line-665"></span><span class="hs-comment">-- @since 1.6.12.0</span><span>
</span><span id="line-666"></span><span class="annot"><a href="System.Process.html#getCurrentPid"><span class="hs-identifier hs-type">getCurrentPid</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="System.Process.html#Pid"><span class="hs-identifier hs-type">Pid</span></a></span><span>
</span><span id="line-667"></span><span id="getCurrentPid"><span class="annot"><span class="annottext">getCurrentPid :: IO Pid
</span><a href="System.Process.html#getCurrentPid"><span class="hs-identifier hs-var hs-var">getCurrentPid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span class="hs-cpp">
#ifdef WINDOWS
</span><span>    </span><span class="annot"><span class="annottext">IO Pid
</span><a href="../../Win32/src/System.Win32.Process.html#getCurrentProcessId"><span class="hs-identifier hs-var">getCurrentProcessId</span></a></span><span class="hs-cpp">
#else
</span><span>    </span><span class="hs-identifier">getProcessID</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-674"></span><span>
</span><span id="line-675"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-676"></span><span class="hs-comment">-- waitForProcess</span><span>
</span><span id="line-677"></span><span>
</span><span id="line-678"></span><span class="hs-comment">{- | Waits for the specified process to terminate, and returns its exit code.

GHC Note: in order to call @waitForProcess@ without blocking all the
other threads in the system, you must compile the program with
@-threaded@.

Note that it is safe to call @waitForProcess@ for the same process in multiple
threads. When the process ends, threads blocking on this call will wake in
FIFO order.

(/Since: 1.2.0.0/) On Unix systems, a negative value @'ExitFailure' -/signum/@
indicates that the child was terminated by signal @/signum/@.
The signal numbers are platform-specific, so to test for a specific signal use
the constants provided by &quot;System.Posix.Signals&quot; in the @unix@ package.
Note: core dumps are not reported, use &quot;System.Posix.Process&quot; if you need this
detail.

-}</span><span>
</span><span id="line-696"></span><span class="annot"><a href="System.Process.html#waitForProcess"><span class="hs-identifier hs-type">waitForProcess</span></a></span><span>
</span><span id="line-697"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span>
</span><span id="line-698"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ExitCode"><span class="hs-identifier hs-type">ExitCode</span></a></span><span>
</span><span id="line-699"></span><span id="waitForProcess"><span class="annot"><span class="annottext">waitForProcess :: ProcessHandle -&gt; IO ExitCode
</span><a href="System.Process.html#waitForProcess"><span class="hs-identifier hs-var hs-var">waitForProcess</span></a></span></span><span> </span><span id="local-6989586621679048397"><span class="annot"><span class="annottext">ph :: ProcessHandle
</span><a href="#local-6989586621679048397"><span class="hs-identifier hs-var">ph</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span> </span><span class="annot"><span class="annottext">MVar ProcessHandle__
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679048396"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048396"><span class="hs-identifier hs-var">delegating_ctlc</span></a></span></span><span> </span><span class="annot"><span class="annottext">MVar ()
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO ExitCode -&gt; IO ExitCode
forall a. IO a -&gt; IO a
</span><a href="#local-6989586621679048395"><span class="hs-identifier hs-var">lockWaitpid</span></a></span><span> </span><span class="annot"><span class="annottext">(IO ExitCode -&gt; IO ExitCode) -&gt; IO ExitCode -&gt; IO ExitCode
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-700"></span><span>  </span><span id="local-6989586621679048394"><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048394"><span class="hs-identifier hs-var">p_</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ProcessHandle
-&gt; (ProcessHandle__ -&gt; IO (ProcessHandle__, ProcessHandle__))
-&gt; IO ProcessHandle__
forall a.
ProcessHandle
-&gt; (ProcessHandle__ -&gt; IO (ProcessHandle__, a)) -&gt; IO a
</span><a href="System.Process.Common.html#modifyProcessHandle"><span class="hs-identifier hs-var">modifyProcessHandle</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048397"><span class="hs-identifier hs-var">ph</span></a></span><span> </span><span class="annot"><span class="annottext">((ProcessHandle__ -&gt; IO (ProcessHandle__, ProcessHandle__))
 -&gt; IO ProcessHandle__)
-&gt; (ProcessHandle__ -&gt; IO (ProcessHandle__, ProcessHandle__))
-&gt; IO ProcessHandle__
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679048392"><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048392"><span class="hs-identifier hs-var">p_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(ProcessHandle__, ProcessHandle__)
-&gt; IO (ProcessHandle__, ProcessHandle__)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048392"><span class="hs-identifier hs-var">p_</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048392"><span class="hs-identifier hs-var">p_</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-701"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048394"><span class="hs-identifier hs-var">p_</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-702"></span><span>    </span><span class="annot"><a href="System.Process.Common.html#ClosedHandle"><span class="hs-identifier hs-type">ClosedHandle</span></a></span><span> </span><span id="local-6989586621679048390"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048390"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ExitCode -&gt; IO ExitCode
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048390"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-703"></span><span>    </span><span class="annot"><a href="System.Process.Common.html#OpenHandle"><span class="hs-identifier hs-type">OpenHandle</span></a></span><span> </span><span id="local-6989586621679048389"><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048389"><span class="hs-identifier hs-var">h</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-704"></span><span>        </span><span class="hs-comment">-- don't hold the MVar while we call c_waitForProcess...</span><span>
</span><span id="line-705"></span><span>        </span><span id="local-6989586621679048388"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048388"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">PHANDLE -&gt; IO ExitCode
</span><a href="#local-6989586621679048387"><span class="hs-identifier hs-var">waitForProcess'</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048389"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-706"></span><span>        </span><span id="local-6989586621679048386"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048386"><span class="hs-identifier hs-var">e'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ProcessHandle
-&gt; (ProcessHandle__ -&gt; IO (ProcessHandle__, ExitCode))
-&gt; IO ExitCode
forall a.
ProcessHandle
-&gt; (ProcessHandle__ -&gt; IO (ProcessHandle__, a)) -&gt; IO a
</span><a href="System.Process.Common.html#modifyProcessHandle"><span class="hs-identifier hs-var">modifyProcessHandle</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048397"><span class="hs-identifier hs-var">ph</span></a></span><span> </span><span class="annot"><span class="annottext">((ProcessHandle__ -&gt; IO (ProcessHandle__, ExitCode))
 -&gt; IO ExitCode)
-&gt; (ProcessHandle__ -&gt; IO (ProcessHandle__, ExitCode))
-&gt; IO ExitCode
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679048385"><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048385"><span class="hs-identifier hs-var">p_'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-707"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048385"><span class="hs-identifier hs-var">p_'</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-708"></span><span>            </span><span class="annot"><a href="System.Process.Common.html#ClosedHandle"><span class="hs-identifier hs-type">ClosedHandle</span></a></span><span> </span><span id="local-6989586621679048384"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048384"><span class="hs-identifier hs-var">e'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(ProcessHandle__, ExitCode) -&gt; IO (ProcessHandle__, ExitCode)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048385"><span class="hs-identifier hs-var">p_'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048384"><span class="hs-identifier hs-var">e'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-709"></span><span>            </span><span class="annot"><a href="System.Process.Common.html#OpenExtHandle"><span class="hs-identifier hs-type">OpenExtHandle</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (ProcessHandle__, ExitCode)
forall (m :: * -&gt; *) a. MonadFail m =&gt; String -&gt; m a
</span><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-identifier hs-var">fail</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;waitForProcess(OpenExtHandle): this cannot happen&quot;</span></span><span>
</span><span id="line-710"></span><span>            </span><span class="annot"><a href="System.Process.Common.html#OpenHandle"><span class="hs-identifier hs-type">OpenHandle</span></a></span><span> </span><span id="local-6989586621679048382"><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048382"><span class="hs-identifier hs-var">ph'</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-711"></span><span>              </span><span class="annot"><span class="annottext">PHANDLE -&gt; IO ()
</span><a href="System.Process.Windows.html#closePHANDLE"><span class="hs-identifier hs-var">closePHANDLE</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048382"><span class="hs-identifier hs-var">ph'</span></a></span><span>
</span><span id="line-712"></span><span>              </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048396"><span class="hs-identifier hs-var">delegating_ctlc</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-713"></span><span>                </span><span class="annot"><span class="annottext">ExitCode -&gt; IO ()
</span><a href="System.Process.Windows.html#endDelegateControlC"><span class="hs-identifier hs-var">endDelegateControlC</span></a></span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048388"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-714"></span><span>              </span><span class="annot"><span class="annottext">(ProcessHandle__, ExitCode) -&gt; IO (ProcessHandle__, ExitCode)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ExitCode -&gt; ProcessHandle__
</span><a href="System.Process.Common.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048388"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048388"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-715"></span><span>        </span><span class="annot"><span class="annottext">ExitCode -&gt; IO ExitCode
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048386"><span class="hs-identifier hs-var">e'</span></a></span><span class="hs-cpp">
#if defined(WINDOWS)
</span><span>    </span><span class="annot"><a href="System.Process.Common.html#OpenExtHandle"><span class="hs-identifier hs-type">OpenExtHandle</span></a></span><span> </span><span id="local-6989586621679048379"><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048379"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679048378"><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048378"><span class="hs-identifier hs-var">job</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-718"></span><span>        </span><span class="hs-comment">-- First wait for completion of the job...</span><span>
</span><span id="line-719"></span><span>        </span><span class="annot"><span class="annottext">PHANDLE -&gt; IO ()
</span><a href="System.Process.Windows.html#waitForJobCompletion"><span class="hs-identifier hs-var">waitForJobCompletion</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048378"><span class="hs-identifier hs-var">job</span></a></span><span>
</span><span id="line-720"></span><span>        </span><span id="local-6989586621679048376"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048376"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">PHANDLE -&gt; IO ExitCode
</span><a href="#local-6989586621679048387"><span class="hs-identifier hs-var">waitForProcess'</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048379"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-721"></span><span>        </span><span id="local-6989586621679048375"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048375"><span class="hs-identifier hs-var">e'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ProcessHandle
-&gt; (ProcessHandle__ -&gt; IO (ProcessHandle__, ExitCode))
-&gt; IO ExitCode
forall a.
ProcessHandle
-&gt; (ProcessHandle__ -&gt; IO (ProcessHandle__, a)) -&gt; IO a
</span><a href="System.Process.Common.html#modifyProcessHandle"><span class="hs-identifier hs-var">modifyProcessHandle</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048397"><span class="hs-identifier hs-var">ph</span></a></span><span> </span><span class="annot"><span class="annottext">((ProcessHandle__ -&gt; IO (ProcessHandle__, ExitCode))
 -&gt; IO ExitCode)
-&gt; (ProcessHandle__ -&gt; IO (ProcessHandle__, ExitCode))
-&gt; IO ExitCode
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679048374"><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048374"><span class="hs-identifier hs-var">p_'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-722"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048374"><span class="hs-identifier hs-var">p_'</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-723"></span><span>            </span><span class="annot"><a href="System.Process.Common.html#ClosedHandle"><span class="hs-identifier hs-type">ClosedHandle</span></a></span><span> </span><span id="local-6989586621679048373"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048373"><span class="hs-identifier hs-var">e'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(ProcessHandle__, ExitCode) -&gt; IO (ProcessHandle__, ExitCode)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048374"><span class="hs-identifier hs-var">p_'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048373"><span class="hs-identifier hs-var">e'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-724"></span><span>            </span><span class="annot"><a href="System.Process.Common.html#OpenHandle"><span class="hs-identifier hs-type">OpenHandle</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (ProcessHandle__, ExitCode)
forall (m :: * -&gt; *) a. MonadFail m =&gt; String -&gt; m a
</span><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-identifier hs-var">fail</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;waitForProcess(OpenHandle): this cannot happen&quot;</span></span><span>
</span><span id="line-725"></span><span>            </span><span class="annot"><a href="System.Process.Common.html#OpenExtHandle"><span class="hs-identifier hs-type">OpenExtHandle</span></a></span><span> </span><span id="local-6989586621679048372"><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048372"><span class="hs-identifier hs-var">ph'</span></a></span></span><span> </span><span id="local-6989586621679048371"><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048371"><span class="hs-identifier hs-var">job'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-726"></span><span>              </span><span class="annot"><span class="annottext">PHANDLE -&gt; IO ()
</span><a href="System.Process.Windows.html#closePHANDLE"><span class="hs-identifier hs-var">closePHANDLE</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048372"><span class="hs-identifier hs-var">ph'</span></a></span><span>
</span><span id="line-727"></span><span>              </span><span class="annot"><span class="annottext">PHANDLE -&gt; IO ()
</span><a href="System.Process.Windows.html#closePHANDLE"><span class="hs-identifier hs-var">closePHANDLE</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048371"><span class="hs-identifier hs-var">job'</span></a></span><span>
</span><span id="line-728"></span><span>              </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048396"><span class="hs-identifier hs-var">delegating_ctlc</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-729"></span><span>                </span><span class="annot"><span class="annottext">ExitCode -&gt; IO ()
</span><a href="System.Process.Windows.html#endDelegateControlC"><span class="hs-identifier hs-var">endDelegateControlC</span></a></span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048376"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-730"></span><span>              </span><span class="annot"><span class="annottext">(ProcessHandle__, ExitCode) -&gt; IO (ProcessHandle__, ExitCode)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ExitCode -&gt; ProcessHandle__
</span><a href="System.Process.Common.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048376"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048376"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-731"></span><span>        </span><span class="annot"><span class="annottext">ExitCode -&gt; IO ExitCode
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048375"><span class="hs-identifier hs-var">e'</span></a></span><span class="hs-cpp">
#else
</span><span>    </span><span class="hs-identifier">OpenExtHandle</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_job</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-734"></span><span>        </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">ExitFailure</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="hs-number">1</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-737"></span><span>    </span><span class="hs-comment">-- If more than one thread calls `waitpid` at a time, `waitpid` will</span><span>
</span><span id="line-738"></span><span>    </span><span class="hs-comment">-- return the exit code to one of them and (-1) to the rest of them,</span><span>
</span><span id="line-739"></span><span>    </span><span class="hs-comment">-- causing an exception to be thrown.</span><span>
</span><span id="line-740"></span><span>    </span><span class="hs-comment">-- Cf. https://github.com/haskell/process/issues/46, and</span><span>
</span><span id="line-741"></span><span>    </span><span class="hs-comment">-- https://github.com/haskell/process/pull/58 for further discussion</span><span>
</span><span id="line-742"></span><span>    </span><span id="local-6989586621679048395"><span class="annot"><span class="annottext">lockWaitpid :: IO b -&gt; IO b
</span><a href="#local-6989586621679048395"><span class="hs-identifier hs-var hs-var">lockWaitpid</span></a></span></span><span> </span><span id="local-6989586621679048370"><span class="annot"><span class="annottext">IO b
</span><a href="#local-6989586621679048370"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MVar () -&gt; (() -&gt; IO b) -&gt; IO b
forall a b. MVar a -&gt; (a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/Control.Concurrent.MVar.html#withMVar"><span class="hs-identifier hs-var">withMVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ProcessHandle -&gt; MVar ()
</span><a href="System.Process.Common.html#waitpidLock"><span class="hs-identifier hs-var hs-var">waitpidLock</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048397"><span class="hs-identifier hs-var">ph</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((() -&gt; IO b) -&gt; IO b) -&gt; (() -&gt; IO b) -&gt; IO b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO b
</span><a href="#local-6989586621679048370"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-743"></span><span>
</span><span id="line-744"></span><span>    </span><span class="annot"><a href="#local-6989586621679048387"><span class="hs-identifier hs-type">waitForProcess'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.DebugApi.html#PHANDLE"><span class="hs-identifier hs-type">PHANDLE</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ExitCode"><span class="hs-identifier hs-type">ExitCode</span></a></span><span>
</span><span id="line-745"></span><span>    </span><span id="local-6989586621679048387"><span class="annot"><span class="annottext">waitForProcess' :: PHANDLE -&gt; IO ExitCode
</span><a href="#local-6989586621679048387"><span class="hs-identifier hs-var hs-var">waitForProcess'</span></a></span></span><span> </span><span id="local-6989586621679048367"><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048367"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Ptr CInt -&gt; IO ExitCode) -&gt; IO ExitCode
forall a b. Storable a =&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/Foreign.Marshal.Alloc.html#alloca"><span class="hs-identifier hs-var">alloca</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr CInt -&gt; IO ExitCode) -&gt; IO ExitCode)
-&gt; (Ptr CInt -&gt; IO ExitCode) -&gt; IO ExitCode
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679048365"><span class="annot"><span class="annottext">Ptr CInt
</span><a href="#local-6989586621679048365"><span class="hs-identifier hs-var">pret</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-746"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO ()
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO ()
</span><a href="../../base/src/Foreign.C.Error.html#throwErrnoIfMinus1Retry_"><span class="hs-identifier hs-var">throwErrnoIfMinus1Retry_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;waitForProcess&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO ()
</span><a href="../../base/src/Control.Exception.html#allowInterrupt"><span class="hs-identifier hs-var">allowInterrupt</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO CInt -&gt; IO CInt
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE -&gt; Ptr CInt -&gt; IO CInt
</span><a href="System.Process.html#c_waitForProcess"><span class="hs-identifier hs-var">c_waitForProcess</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048367"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CInt
</span><a href="#local-6989586621679048365"><span class="hs-identifier hs-var">pret</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-747"></span><span>      </span><span class="annot"><span class="annottext">CInt -&gt; ExitCode
</span><a href="#local-6989586621679048362"><span class="hs-identifier hs-var">mkExitCode</span></a></span><span> </span><span class="annot"><span class="annottext">(CInt -&gt; ExitCode) -&gt; IO CInt -&gt; IO ExitCode
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CInt -&gt; IO CInt
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CInt
</span><a href="#local-6989586621679048365"><span class="hs-identifier hs-var">pret</span></a></span><span>
</span><span id="line-748"></span><span>
</span><span id="line-749"></span><span>    </span><span class="annot"><a href="#local-6989586621679048362"><span class="hs-identifier hs-type">mkExitCode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ExitCode"><span class="hs-identifier hs-type">ExitCode</span></a></span><span>
</span><span id="line-750"></span><span>    </span><span id="local-6989586621679048362"><span class="annot"><span class="annottext">mkExitCode :: CInt -&gt; ExitCode
</span><a href="#local-6989586621679048362"><span class="hs-identifier hs-var hs-var">mkExitCode</span></a></span></span><span> </span><span id="local-6989586621679048359"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679048359"><span class="hs-identifier hs-var">code</span></a></span></span><span>
</span><span id="line-751"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679048359"><span class="hs-identifier hs-var">code</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="../../base/src/GHC.IO.Exception.html#ExitSuccess"><span class="hs-identifier hs-var">ExitSuccess</span></a></span><span>
</span><span id="line-752"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ExitCode
</span><a href="../../base/src/GHC.IO.Exception.html#ExitFailure"><span class="hs-identifier hs-var">ExitFailure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679048359"><span class="hs-identifier hs-var">code</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-753"></span><span>
</span><span id="line-754"></span><span>
</span><span id="line-755"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-756"></span><span class="hs-comment">-- getProcessExitCode</span><span>
</span><span id="line-757"></span><span>
</span><span id="line-758"></span><span class="hs-comment">{- |
This is a non-blocking version of 'waitForProcess'.  If the process is
still running, 'Nothing' is returned.  If the process has exited, then
@'Just' e@ is returned where @e@ is the exit code of the process.

On Unix systems, see 'waitForProcess' for the meaning of exit codes
when the process died as the result of a signal.
-}</span><span>
</span><span id="line-766"></span><span>
</span><span id="line-767"></span><span class="annot"><a href="System.Process.html#getProcessExitCode"><span class="hs-identifier hs-type">getProcessExitCode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ExitCode"><span class="hs-identifier hs-type">ExitCode</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-768"></span><span id="getProcessExitCode"><span class="annot"><span class="annottext">getProcessExitCode :: ProcessHandle -&gt; IO (Maybe ExitCode)
</span><a href="System.Process.html#getProcessExitCode"><span class="hs-identifier hs-var hs-var">getProcessExitCode</span></a></span></span><span> </span><span id="local-6989586621679048358"><span class="annot"><span class="annottext">ph :: ProcessHandle
</span><a href="#local-6989586621679048358"><span class="hs-identifier hs-var">ph</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span> </span><span class="annot"><span class="annottext">MVar ProcessHandle__
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679048357"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048357"><span class="hs-identifier hs-var">delegating_ctlc</span></a></span></span><span> </span><span class="annot"><span class="annottext">MVar ()
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO (Maybe ExitCode) -&gt; IO (Maybe ExitCode)
</span><a href="#local-6989586621679048356"><span class="hs-identifier hs-var">tryLockWaitpid</span></a></span><span> </span><span class="annot"><span class="annottext">(IO (Maybe ExitCode) -&gt; IO (Maybe ExitCode))
-&gt; IO (Maybe ExitCode) -&gt; IO (Maybe ExitCode)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-769"></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621679048355"><span class="annot"><span class="annottext">Maybe ExitCode
</span><a href="#local-6989586621679048355"><span class="hs-identifier hs-var">m_e</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048354"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048354"><span class="hs-identifier hs-var">was_open</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ProcessHandle
-&gt; (ProcessHandle__
    -&gt; IO (ProcessHandle__, (Maybe ExitCode, Bool)))
-&gt; IO (Maybe ExitCode, Bool)
forall a.
ProcessHandle
-&gt; (ProcessHandle__ -&gt; IO (ProcessHandle__, a)) -&gt; IO a
</span><a href="System.Process.Common.html#modifyProcessHandle"><span class="hs-identifier hs-var">modifyProcessHandle</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048358"><span class="hs-identifier hs-var">ph</span></a></span><span> </span><span class="annot"><span class="annottext">((ProcessHandle__ -&gt; IO (ProcessHandle__, (Maybe ExitCode, Bool)))
 -&gt; IO (Maybe ExitCode, Bool))
-&gt; (ProcessHandle__
    -&gt; IO (ProcessHandle__, (Maybe ExitCode, Bool)))
-&gt; IO (Maybe ExitCode, Bool)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679048353"><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048353"><span class="hs-identifier hs-var">p_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-770"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048353"><span class="hs-identifier hs-var">p_</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-771"></span><span>      </span><span class="annot"><a href="System.Process.Common.html#ClosedHandle"><span class="hs-identifier hs-type">ClosedHandle</span></a></span><span> </span><span id="local-6989586621679048352"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048352"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(ProcessHandle__, (Maybe ExitCode, Bool))
-&gt; IO (ProcessHandle__, (Maybe ExitCode, Bool))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048353"><span class="hs-identifier hs-var">p_</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ExitCode -&gt; Maybe ExitCode
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048352"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-772"></span><span>      </span><span id="local-6989586621679048351"><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048351"><span class="hs-identifier hs-var">open</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-773"></span><span>        </span><span class="annot"><span class="annottext">(Ptr CInt -&gt; IO (ProcessHandle__, (Maybe ExitCode, Bool)))
-&gt; IO (ProcessHandle__, (Maybe ExitCode, Bool))
forall a b. Storable a =&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/Foreign.Marshal.Alloc.html#alloca"><span class="hs-identifier hs-var">alloca</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr CInt -&gt; IO (ProcessHandle__, (Maybe ExitCode, Bool)))
 -&gt; IO (ProcessHandle__, (Maybe ExitCode, Bool)))
-&gt; (Ptr CInt -&gt; IO (ProcessHandle__, (Maybe ExitCode, Bool)))
-&gt; IO (ProcessHandle__, (Maybe ExitCode, Bool))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679048350"><span class="annot"><span class="annottext">Ptr CInt
</span><a href="#local-6989586621679048350"><span class="hs-identifier hs-var">pExitCode</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-774"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ProcessHandle__ -&gt; Maybe PHANDLE
</span><a href="#local-6989586621679048349"><span class="hs-identifier hs-var">getHandle</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048351"><span class="hs-identifier hs-var">open</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-775"></span><span>            </span><span class="annot"><span class="annottext">Maybe PHANDLE
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(ProcessHandle__, (Maybe ExitCode, Bool))
-&gt; IO (ProcessHandle__, (Maybe ExitCode, Bool))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048353"><span class="hs-identifier hs-var">p_</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe ExitCode
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-776"></span><span>            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679048348"><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048348"><span class="hs-identifier hs-var">h</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-777"></span><span>                </span><span id="local-6989586621679048347"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679048347"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO CInt
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="../../base/src/Foreign.C.Error.html#throwErrnoIfMinus1Retry"><span class="hs-identifier hs-var">throwErrnoIfMinus1Retry</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;getProcessExitCode&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO CInt) -&gt; IO CInt -&gt; IO CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-778"></span><span>                                        </span><span class="annot"><span class="annottext">PHANDLE -&gt; Ptr CInt -&gt; IO CInt
</span><a href="System.Process.html#c_getProcessExitCode"><span class="hs-identifier hs-var">c_getProcessExitCode</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048348"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CInt
</span><a href="#local-6989586621679048350"><span class="hs-identifier hs-var">pExitCode</span></a></span><span>
</span><span id="line-779"></span><span>                </span><span id="local-6989586621679048344"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679048344"><span class="hs-identifier hs-var">code</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr CInt -&gt; IO CInt
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CInt
</span><a href="#local-6989586621679048350"><span class="hs-identifier hs-var">pExitCode</span></a></span><span>
</span><span id="line-780"></span><span>                </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679048347"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">0</span></span><span>
</span><span id="line-781"></span><span>                   </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">(ProcessHandle__, (Maybe ExitCode, Bool))
-&gt; IO (ProcessHandle__, (Maybe ExitCode, Bool))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048353"><span class="hs-identifier hs-var">p_</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe ExitCode
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-782"></span><span>                   </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-783"></span><span>                        </span><span class="annot"><span class="annottext">PHANDLE -&gt; IO ()
</span><a href="System.Process.Windows.html#closePHANDLE"><span class="hs-identifier hs-var">closePHANDLE</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048348"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-784"></span><span>                        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679048339"><span class="annot"><span class="annottext">e :: ExitCode
</span><a href="#local-6989586621679048339"><span class="hs-identifier hs-var hs-var">e</span></a></span></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679048344"><span class="hs-identifier hs-var">code</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="../../base/src/GHC.IO.Exception.html#ExitSuccess"><span class="hs-identifier hs-var">ExitSuccess</span></a></span><span>
</span><span id="line-785"></span><span>                               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ExitCode
</span><a href="../../base/src/GHC.IO.Exception.html#ExitFailure"><span class="hs-identifier hs-var">ExitFailure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679048344"><span class="hs-identifier hs-var">code</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-786"></span><span>                        </span><span class="annot"><span class="annottext">(ProcessHandle__, (Maybe ExitCode, Bool))
-&gt; IO (ProcessHandle__, (Maybe ExitCode, Bool))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ExitCode -&gt; ProcessHandle__
</span><a href="System.Process.Common.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048339"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ExitCode -&gt; Maybe ExitCode
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048339"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-787"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe ExitCode
</span><a href="#local-6989586621679048355"><span class="hs-identifier hs-var">m_e</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-788"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679048338"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048338"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048354"><span class="hs-identifier hs-var">was_open</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048357"><span class="hs-identifier hs-var">delegating_ctlc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ExitCode -&gt; IO ()
</span><a href="System.Process.Windows.html#endDelegateControlC"><span class="hs-identifier hs-var">endDelegateControlC</span></a></span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621679048338"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-789"></span><span>    </span><span class="annot"><span class="annottext">Maybe ExitCode
</span><span class="hs-identifier">_</span></span><span>                                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-790"></span><span>  </span><span class="annot"><span class="annottext">Maybe ExitCode -&gt; IO (Maybe ExitCode)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe ExitCode
</span><a href="#local-6989586621679048355"><span class="hs-identifier hs-var">m_e</span></a></span><span>
</span><span id="line-791"></span><span>    </span><span class="hs-keyword">where</span><span> </span><span class="annot"><a href="#local-6989586621679048349"><span class="hs-identifier hs-type">getHandle</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Process.Common.html#ProcessHandle__"><span class="hs-identifier hs-type">ProcessHandle__</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.DebugApi.html#PHANDLE"><span class="hs-identifier hs-type">PHANDLE</span></a></span><span>
</span><span id="line-792"></span><span>          </span><span id="local-6989586621679048349"><span class="annot"><span class="annottext">getHandle :: ProcessHandle__ -&gt; Maybe PHANDLE
</span><a href="#local-6989586621679048349"><span class="hs-identifier hs-var hs-var">getHandle</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="System.Process.Common.html#OpenHandle"><span class="hs-identifier hs-type">OpenHandle</span></a></span><span>        </span><span id="local-6989586621679048337"><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048337"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PHANDLE -&gt; Maybe PHANDLE
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048337"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-793"></span><span>          </span><span class="annot"><a href="#local-6989586621679048349"><span class="hs-identifier hs-var">getHandle</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="System.Process.Common.html#ClosedHandle"><span class="hs-identifier hs-type">ClosedHandle</span></a></span><span>      </span><span class="annot"><span class="annottext">ExitCode
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe PHANDLE
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-794"></span><span>          </span><span class="annot"><a href="#local-6989586621679048349"><span class="hs-identifier hs-var">getHandle</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="System.Process.Common.html#OpenExtHandle"><span class="hs-identifier hs-type">OpenExtHandle</span></a></span><span>   </span><span id="local-6989586621679048336"><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048336"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="annot"><span class="annottext">PHANDLE
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PHANDLE -&gt; Maybe PHANDLE
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048336"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-795"></span><span>
</span><span id="line-796"></span><span>          </span><span class="hs-comment">-- If somebody is currently holding the waitpid lock, we don't want to</span><span>
</span><span id="line-797"></span><span>          </span><span class="hs-comment">-- accidentally remove the pid from the process table.</span><span>
</span><span id="line-798"></span><span>          </span><span class="hs-comment">-- Try acquiring the waitpid lock. If it is held, we are done</span><span>
</span><span id="line-799"></span><span>          </span><span class="hs-comment">-- since that means the process is still running and we can return</span><span>
</span><span id="line-800"></span><span>          </span><span class="hs-comment">-- `Nothing`. If it is not held, acquire it so we can run the</span><span>
</span><span id="line-801"></span><span>          </span><span class="hs-comment">-- (non-blocking) call to `waitpid` without worrying about any</span><span>
</span><span id="line-802"></span><span>          </span><span class="hs-comment">-- other threads calling it at the same time.</span><span>
</span><span id="line-803"></span><span>          </span><span class="annot"><a href="#local-6989586621679048356"><span class="hs-identifier hs-type">tryLockWaitpid</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ExitCode"><span class="hs-identifier hs-type">ExitCode</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ExitCode"><span class="hs-identifier hs-type">ExitCode</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-804"></span><span>          </span><span id="local-6989586621679048356"><span class="annot"><span class="annottext">tryLockWaitpid :: IO (Maybe ExitCode) -&gt; IO (Maybe ExitCode)
</span><a href="#local-6989586621679048356"><span class="hs-identifier hs-var hs-var">tryLockWaitpid</span></a></span></span><span> </span><span id="local-6989586621679048335"><span class="annot"><span class="annottext">IO (Maybe ExitCode)
</span><a href="#local-6989586621679048335"><span class="hs-identifier hs-var">action</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO (Maybe ())
-&gt; (Maybe () -&gt; IO ())
-&gt; (Maybe () -&gt; IO (Maybe ExitCode))
-&gt; IO (Maybe ExitCode)
forall a b c. IO a -&gt; (a -&gt; IO b) -&gt; (a -&gt; IO c) -&gt; IO c
</span><a href="../../base/src/Control.Exception.Base.html#bracket"><span class="hs-identifier hs-var">bracket</span></a></span><span> </span><span class="annot"><span class="annottext">IO (Maybe ())
</span><a href="#local-6989586621679048334"><span class="hs-identifier hs-var">acquire</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe () -&gt; IO ()
</span><a href="#local-6989586621679048333"><span class="hs-identifier hs-var">release</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe () -&gt; IO (Maybe ExitCode)
</span><a href="#local-6989586621679048332"><span class="hs-identifier hs-var">between</span></a></span><span>
</span><span id="line-805"></span><span>            </span><span class="hs-keyword">where</span><span>
</span><span id="line-806"></span><span>              </span><span id="local-6989586621679048334"><span class="annot"><span class="annottext">acquire :: IO (Maybe ())
</span><a href="#local-6989586621679048334"><span class="hs-identifier hs-var hs-var">acquire</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MVar () -&gt; IO (Maybe ())
forall a. MVar a -&gt; IO (Maybe a)
</span><a href="../../base/src/GHC.MVar.html#tryTakeMVar"><span class="hs-identifier hs-var">tryTakeMVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ProcessHandle -&gt; MVar ()
</span><a href="System.Process.Common.html#waitpidLock"><span class="hs-identifier hs-var hs-var">waitpidLock</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048358"><span class="hs-identifier hs-var">ph</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-807"></span><span>              </span><span id="local-6989586621679048333"><span class="annot"><span class="annottext">release :: Maybe () -&gt; IO ()
</span><a href="#local-6989586621679048333"><span class="hs-identifier hs-var hs-var">release</span></a></span></span><span> </span><span id="local-6989586621679048329"><span class="annot"><span class="annottext">Maybe ()
</span><a href="#local-6989586621679048329"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe ()
</span><a href="#local-6989586621679048329"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-808"></span><span>                </span><span class="annot"><span class="annottext">Maybe ()
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-809"></span><span>                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MVar () -&gt; () -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="../../base/src/GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ProcessHandle -&gt; MVar ()
</span><a href="System.Process.Common.html#waitpidLock"><span class="hs-identifier hs-var hs-var">waitpidLock</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048358"><span class="hs-identifier hs-var">ph</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-810"></span><span>              </span><span id="local-6989586621679048332"><span class="annot"><span class="annottext">between :: Maybe () -&gt; IO (Maybe ExitCode)
</span><a href="#local-6989586621679048332"><span class="hs-identifier hs-var hs-var">between</span></a></span></span><span> </span><span id="local-6989586621679048327"><span class="annot"><span class="annottext">Maybe ()
</span><a href="#local-6989586621679048327"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe ()
</span><a href="#local-6989586621679048327"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-811"></span><span>                </span><span class="annot"><span class="annottext">Maybe ()
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe ExitCode -&gt; IO (Maybe ExitCode)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe ExitCode
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-812"></span><span>                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO (Maybe ExitCode)
</span><a href="#local-6989586621679048335"><span class="hs-identifier hs-var">action</span></a></span><span>
</span><span id="line-813"></span><span>
</span><span id="line-814"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-815"></span><span class="hs-comment">-- terminateProcess</span><span>
</span><span id="line-816"></span><span>
</span><span id="line-817"></span><span class="hs-comment">-- | Attempts to terminate the specified process.  This function should</span><span>
</span><span id="line-818"></span><span class="hs-comment">-- not be used under normal circumstances - no guarantees are given regarding</span><span>
</span><span id="line-819"></span><span class="hs-comment">-- how cleanly the process is terminated.  To check whether the process</span><span>
</span><span id="line-820"></span><span class="hs-comment">-- has indeed terminated, use 'getProcessExitCode'.</span><span>
</span><span id="line-821"></span><span class="hs-comment">--</span><span>
</span><span id="line-822"></span><span class="hs-comment">-- On Unix systems, 'terminateProcess' sends the process the SIGTERM signal.</span><span>
</span><span id="line-823"></span><span class="hs-comment">-- On Windows systems, if `use_process_jobs` is `True` then the Win32 @TerminateJobObject@</span><span>
</span><span id="line-824"></span><span class="hs-comment">-- function is called to kill all processes associated with the job and passing the</span><span>
</span><span id="line-825"></span><span class="hs-comment">-- exit code of 1 to each of them. Otherwise if `use_process_jobs` is `False` then the</span><span>
</span><span id="line-826"></span><span class="hs-comment">-- Win32 @TerminateProcess@ function is called, passing an exit code of 1.</span><span>
</span><span id="line-827"></span><span class="hs-comment">--</span><span>
</span><span id="line-828"></span><span class="hs-comment">-- Note: on Windows, if the process was a shell command created by</span><span>
</span><span id="line-829"></span><span class="hs-comment">-- 'createProcess' with 'shell', or created by 'runCommand' or</span><span>
</span><span id="line-830"></span><span class="hs-comment">-- 'runInteractiveCommand', then 'terminateProcess' will only</span><span>
</span><span id="line-831"></span><span class="hs-comment">-- terminate the shell, not the command itself.  On Unix systems, both</span><span>
</span><span id="line-832"></span><span class="hs-comment">-- processes are in a process group and will be terminated together.</span><span>
</span><span id="line-833"></span><span>
</span><span id="line-834"></span><span class="annot"><a href="System.Process.html#terminateProcess"><span class="hs-identifier hs-type">terminateProcess</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-835"></span><span id="terminateProcess"><span class="annot"><span class="annottext">terminateProcess :: ProcessHandle -&gt; IO ()
</span><a href="System.Process.html#terminateProcess"><span class="hs-identifier hs-var hs-var">terminateProcess</span></a></span></span><span> </span><span id="local-6989586621679048326"><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048326"><span class="hs-identifier hs-var">ph</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-836"></span><span>  </span><span class="annot"><span class="annottext">ProcessHandle -&gt; (ProcessHandle__ -&gt; IO ()) -&gt; IO ()
forall a. ProcessHandle -&gt; (ProcessHandle__ -&gt; IO a) -&gt; IO a
</span><a href="System.Process.Common.html#withProcessHandle"><span class="hs-identifier hs-var">withProcessHandle</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048326"><span class="hs-identifier hs-var">ph</span></a></span><span> </span><span class="annot"><span class="annottext">((ProcessHandle__ -&gt; IO ()) -&gt; IO ())
-&gt; (ProcessHandle__ -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679048324"><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048324"><span class="hs-identifier hs-var">p_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-837"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048324"><span class="hs-identifier hs-var">p_</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-838"></span><span>      </span><span class="annot"><a href="System.Process.Common.html#ClosedHandle"><span class="hs-identifier hs-type">ClosedHandle</span></a></span><span>  </span><span class="annot"><span class="annottext">ExitCode
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-cpp">
#if defined(WINDOWS)
</span><span>      </span><span class="annot"><a href="System.Process.Common.html#OpenExtHandle"><span class="hs-identifier hs-type">OpenExtHandle</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ProcessHandle__ -&gt; CUInt -&gt; IO Bool
</span><a href="System.Process.Windows.html#terminateJobUnsafe"><span class="hs-identifier hs-var">terminateJobUnsafe</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle__
</span><a href="#local-6989586621679048324"><span class="hs-identifier hs-var">p_</span></a></span><span> </span><span class="annot"><span class="annottext">CUInt
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">IO Bool -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span>      </span><span class="hs-identifier">OpenExtHandle</span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">error</span><span> </span><span class="hs-string">&quot;terminateProcess with OpenExtHandle should not happen on POSIX.&quot;</span><span class="hs-cpp">
#endif
</span><span>      </span><span class="annot"><a href="System.Process.Common.html#OpenHandle"><span class="hs-identifier hs-type">OpenHandle</span></a></span><span>    </span><span id="local-6989586621679048322"><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048322"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-845"></span><span>        </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO ()
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO ()
</span><a href="../../base/src/Foreign.C.Error.html#throwErrnoIfMinus1Retry_"><span class="hs-identifier hs-var">throwErrnoIfMinus1Retry_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;terminateProcess&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO ()) -&gt; IO CInt -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE -&gt; IO CInt
</span><a href="System.Process.html#c_terminateProcess"><span class="hs-identifier hs-var">c_terminateProcess</span></a></span><span> </span><span class="annot"><span class="annottext">PHANDLE
</span><a href="#local-6989586621679048322"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-846"></span><span>        </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-847"></span><span>        </span><span class="hs-comment">-- does not close the handle, we might want to try terminating it</span><span>
</span><span id="line-848"></span><span>        </span><span class="hs-comment">-- again, or get its exit code.</span><span>
</span><span id="line-849"></span><span>
</span><span id="line-850"></span><span>
</span><span id="line-851"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-852"></span><span class="hs-comment">-- Interface to C bits</span><span>
</span><span id="line-853"></span><span>
</span><span id="line-854"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;terminateProcess&quot;</span></span><span>
</span><span id="line-855"></span><span>  </span><span id="c_terminateProcess"><span class="annot"><a href="System.Process.html#c_terminateProcess"><span class="hs-identifier hs-var">c_terminateProcess</span></a></span></span><span>
</span><span id="line-856"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.DebugApi.html#PHANDLE"><span class="hs-identifier hs-type">PHANDLE</span></a></span><span>
</span><span id="line-857"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-858"></span><span>
</span><span id="line-859"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;getProcessExitCode&quot;</span></span><span>
</span><span id="line-860"></span><span>  </span><span id="c_getProcessExitCode"><span class="annot"><a href="System.Process.html#c_getProcessExitCode"><span class="hs-identifier hs-var">c_getProcessExitCode</span></a></span></span><span>
</span><span id="line-861"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.DebugApi.html#PHANDLE"><span class="hs-identifier hs-type">PHANDLE</span></a></span><span>
</span><span id="line-862"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-863"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-864"></span><span>
</span><span id="line-865"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">interruptible</span></span><span> </span><span class="annot"><span class="hs-string">&quot;waitForProcess&quot;</span></span><span> </span><span class="hs-comment">-- NB. safe - can block</span><span>
</span><span id="line-866"></span><span>  </span><span id="c_waitForProcess"><span class="annot"><a href="System.Process.html#c_waitForProcess"><span class="hs-identifier hs-var">c_waitForProcess</span></a></span></span><span>
</span><span id="line-867"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.DebugApi.html#PHANDLE"><span class="hs-identifier hs-type">PHANDLE</span></a></span><span>
</span><span id="line-868"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-869"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-870"></span><span>
</span><span id="line-871"></span><span>
</span><span id="line-872"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-873"></span><span class="hs-comment">-- Old deprecated variants</span><span>
</span><span id="line-874"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-875"></span><span>
</span><span id="line-876"></span><span class="hs-comment">-- TODO: We're not going to mark these functions as DEPRECATED immediately in</span><span>
</span><span id="line-877"></span><span class="hs-comment">-- process-1.2.0.0. That's because some of their replacements have not been</span><span>
</span><span id="line-878"></span><span class="hs-comment">-- around for all that long. But they should eventually be marked with a</span><span>
</span><span id="line-879"></span><span class="hs-comment">-- suitable DEPRECATED pragma after a release or two.</span><span>
</span><span id="line-880"></span><span>
</span><span id="line-881"></span><span>
</span><span id="line-882"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-883"></span><span class="hs-comment">-- runCommand</span><span>
</span><span id="line-884"></span><span>
</span><span id="line-885"></span><span class="hs-comment">--TODO: in a later release {-# DEPRECATED runCommand &quot;Use 'spawnCommand' instead&quot; #-}</span><span>
</span><span id="line-886"></span><span>
</span><span id="line-887"></span><span class="hs-comment">{- | Runs a command using the shell.
 -}</span><span>
</span><span id="line-889"></span><span class="annot"><a href="System.Process.html#runCommand"><span class="hs-identifier hs-type">runCommand</span></a></span><span>
</span><span id="line-890"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-891"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span>
</span><span id="line-892"></span><span>
</span><span id="line-893"></span><span id="runCommand"><span class="annot"><span class="annottext">runCommand :: String -&gt; IO ProcessHandle
</span><a href="System.Process.html#runCommand"><span class="hs-identifier hs-var hs-var">runCommand</span></a></span></span><span> </span><span id="local-6989586621679048320"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048320"><span class="hs-identifier hs-var">string</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-894"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621679048319"><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048319"><span class="hs-identifier hs-var">ph</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String
-&gt; CreateProcess
-&gt; IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
</span><a href="System.Process.Internals.html#createProcess_"><span class="hs-identifier hs-var">createProcess_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;runCommand&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CreateProcess
</span><a href="System.Process.html#shell"><span class="hs-identifier hs-var">shell</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048320"><span class="hs-identifier hs-var">string</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-895"></span><span>  </span><span class="annot"><span class="annottext">ProcessHandle -&gt; IO ProcessHandle
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048319"><span class="hs-identifier hs-var">ph</span></a></span><span>
</span><span id="line-896"></span><span>
</span><span id="line-897"></span><span>
</span><span id="line-898"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-899"></span><span class="hs-comment">-- runProcess</span><span>
</span><span id="line-900"></span><span>
</span><span id="line-901"></span><span class="hs-comment">--TODO: in a later release {-# DEPRECATED runProcess &quot;Use 'spawnProcess' or 'createProcess' instead&quot; #-}</span><span>
</span><span id="line-902"></span><span>
</span><span id="line-903"></span><span class="hs-comment">{- | Runs a raw command, optionally specifying 'Handle's from which to
     take the @stdin@, @stdout@ and @stderr@ channels for the new
     process (otherwise these handles are inherited from the current
     process).

     Any 'Handle's passed to 'runProcess' are placed immediately in the
     closed state.

     Note: consider using the more general 'createProcess' instead of
     'runProcess'.
-}</span><span>
</span><span id="line-914"></span><span class="annot"><a href="System.Process.html#runProcess"><span class="hs-identifier hs-type">runProcess</span></a></span><span>
</span><span id="line-915"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>                   </span><span class="hs-comment">-- ^ Filename of the executable (see 'RawCommand' for details)</span><span>
</span><span id="line-916"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span>                   </span><span class="hs-comment">-- ^ Arguments to pass to the executable</span><span>
</span><span id="line-917"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>             </span><span class="hs-comment">-- ^ Optional path to the working directory</span><span>
</span><span id="line-918"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>    </span><span class="hs-comment">-- ^ Optional environment (otherwise inherit)</span><span>
</span><span id="line-919"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span>               </span><span class="hs-comment">-- ^ Handle to use for @stdin@ (Nothing =&gt; use existing @stdin@)</span><span>
</span><span id="line-920"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span>               </span><span class="hs-comment">-- ^ Handle to use for @stdout@ (Nothing =&gt; use existing @stdout@)</span><span>
</span><span id="line-921"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span>               </span><span class="hs-comment">-- ^ Handle to use for @stderr@ (Nothing =&gt; use existing @stderr@)</span><span>
</span><span id="line-922"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span>
</span><span id="line-923"></span><span>
</span><span id="line-924"></span><span id="runProcess"><span class="annot"><span class="annottext">runProcess :: String
-&gt; [String]
-&gt; Maybe String
-&gt; Maybe [(String, String)]
-&gt; Maybe Handle
-&gt; Maybe Handle
-&gt; Maybe Handle
-&gt; IO ProcessHandle
</span><a href="System.Process.html#runProcess"><span class="hs-identifier hs-var hs-var">runProcess</span></a></span></span><span> </span><span id="local-6989586621679048318"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048318"><span class="hs-identifier hs-var">cmd</span></a></span></span><span> </span><span id="local-6989586621679048317"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048317"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621679048316"><span class="annot"><span class="annottext">Maybe String
</span><a href="#local-6989586621679048316"><span class="hs-identifier hs-var">mb_cwd</span></a></span></span><span> </span><span id="local-6989586621679048315"><span class="annot"><span class="annottext">Maybe [(String, String)]
</span><a href="#local-6989586621679048315"><span class="hs-identifier hs-var">mb_env</span></a></span></span><span> </span><span id="local-6989586621679048314"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048314"><span class="hs-identifier hs-var">mb_stdin</span></a></span></span><span> </span><span id="local-6989586621679048313"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048313"><span class="hs-identifier hs-var">mb_stdout</span></a></span></span><span> </span><span id="local-6989586621679048312"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048312"><span class="hs-identifier hs-var">mb_stderr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-925"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621679048311"><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048311"><span class="hs-identifier hs-var">ph</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span>
</span><span id="line-926"></span><span>      </span><span class="annot"><span class="annottext">String
-&gt; CreateProcess
-&gt; IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
</span><a href="System.Process.Internals.html#createProcess_"><span class="hs-identifier hs-var">createProcess_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;runProcess&quot;</span></span><span>
</span><span id="line-927"></span><span>         </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; CreateProcess
</span><a href="System.Process.html#proc"><span class="hs-identifier hs-var">proc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048318"><span class="hs-identifier hs-var">cmd</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048317"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cwd :: Maybe String
</span><a href="System.Process.Common.html#cwd"><span class="hs-identifier hs-var">cwd</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe String
</span><a href="#local-6989586621679048316"><span class="hs-identifier hs-var">mb_cwd</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-928"></span><span>                          </span><span class="annot"><span class="annottext">env :: Maybe [(String, String)]
</span><a href="System.Process.Common.html#env"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe [(String, String)]
</span><a href="#local-6989586621679048315"><span class="hs-identifier hs-var">mb_env</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-929"></span><span>                          </span><span class="annot"><span class="annottext">std_in :: StdStream
</span><a href="System.Process.Common.html#std_in"><span class="hs-identifier hs-var">std_in</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Handle -&gt; StdStream
</span><a href="#local-6989586621679048310"><span class="hs-identifier hs-var">mbToStd</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048314"><span class="hs-identifier hs-var">mb_stdin</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-930"></span><span>                          </span><span class="annot"><span class="annottext">std_out :: StdStream
</span><a href="System.Process.Common.html#std_out"><span class="hs-identifier hs-var">std_out</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Handle -&gt; StdStream
</span><a href="#local-6989586621679048310"><span class="hs-identifier hs-var">mbToStd</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048313"><span class="hs-identifier hs-var">mb_stdout</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-931"></span><span>                          </span><span class="annot"><span class="annottext">std_err :: StdStream
</span><a href="System.Process.Common.html#std_err"><span class="hs-identifier hs-var">std_err</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Handle -&gt; StdStream
</span><a href="#local-6989586621679048310"><span class="hs-identifier hs-var">mbToStd</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048312"><span class="hs-identifier hs-var">mb_stderr</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-932"></span><span>  </span><span class="annot"><span class="annottext">Maybe Handle -&gt; IO ()
</span><a href="#local-6989586621679048309"><span class="hs-identifier hs-var">maybeClose</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048314"><span class="hs-identifier hs-var">mb_stdin</span></a></span><span>
</span><span id="line-933"></span><span>  </span><span class="annot"><span class="annottext">Maybe Handle -&gt; IO ()
</span><a href="#local-6989586621679048309"><span class="hs-identifier hs-var">maybeClose</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048313"><span class="hs-identifier hs-var">mb_stdout</span></a></span><span>
</span><span id="line-934"></span><span>  </span><span class="annot"><span class="annottext">Maybe Handle -&gt; IO ()
</span><a href="#local-6989586621679048309"><span class="hs-identifier hs-var">maybeClose</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048312"><span class="hs-identifier hs-var">mb_stderr</span></a></span><span>
</span><span id="line-935"></span><span>  </span><span class="annot"><span class="annottext">ProcessHandle -&gt; IO ProcessHandle
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048311"><span class="hs-identifier hs-var">ph</span></a></span><span>
</span><span id="line-936"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-937"></span><span>  </span><span class="annot"><a href="#local-6989586621679048309"><span class="hs-identifier hs-type">maybeClose</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-938"></span><span>  </span><span id="local-6989586621679048309"><span class="annot"><span class="annottext">maybeClose :: Maybe Handle -&gt; IO ()
</span><a href="#local-6989586621679048309"><span class="hs-identifier hs-var hs-var">maybeClose</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span>  </span><span id="local-6989586621679048308"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048308"><span class="hs-identifier hs-var">hdl</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-939"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048308"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Handle -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#stdin"><span class="hs-identifier hs-var">stdin</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048308"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Handle -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#stdout"><span class="hs-identifier hs-var">stdout</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048308"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Handle -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#stderr"><span class="hs-identifier hs-var">stderr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048308"><span class="hs-identifier hs-var">hdl</span></a></span><span>
</span><span id="line-940"></span><span>  </span><span class="annot"><a href="#local-6989586621679048309"><span class="hs-identifier hs-var">maybeClose</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-941"></span><span>
</span><span id="line-942"></span><span>  </span><span class="annot"><a href="#local-6989586621679048310"><span class="hs-identifier hs-type">mbToStd</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Process.Common.html#StdStream"><span class="hs-identifier hs-type">StdStream</span></a></span><span>
</span><span id="line-943"></span><span>  </span><span id="local-6989586621679048310"><span class="annot"><span class="annottext">mbToStd :: Maybe Handle -&gt; StdStream
</span><a href="#local-6989586621679048310"><span class="hs-identifier hs-var hs-var">mbToStd</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#Inherit"><span class="hs-identifier hs-var">Inherit</span></a></span><span>
</span><span id="line-944"></span><span>  </span><span class="annot"><a href="#local-6989586621679048310"><span class="hs-identifier hs-var">mbToStd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679048307"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048307"><span class="hs-identifier hs-var">hdl</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; StdStream
</span><a href="System.Process.Common.html#UseHandle"><span class="hs-identifier hs-var">UseHandle</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048307"><span class="hs-identifier hs-var">hdl</span></a></span><span>
</span><span id="line-945"></span><span>
</span><span id="line-946"></span><span>
</span><span id="line-947"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-948"></span><span class="hs-comment">-- runInteractiveCommand</span><span>
</span><span id="line-949"></span><span>
</span><span id="line-950"></span><span class="hs-comment">--TODO: in a later release {-# DEPRECATED runInteractiveCommand &quot;Use 'createProcess' instead&quot; #-}</span><span>
</span><span id="line-951"></span><span>
</span><span id="line-952"></span><span class="hs-comment">{- | Runs a command using the shell, and returns 'Handle's that may
     be used to communicate with the process via its @stdin@, @stdout@,
     and @stderr@ respectively.
-}</span><span>
</span><span id="line-956"></span><span class="annot"><a href="System.Process.html#runInteractiveCommand"><span class="hs-identifier hs-type">runInteractiveCommand</span></a></span><span>
</span><span id="line-957"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-958"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-959"></span><span>
</span><span id="line-960"></span><span id="runInteractiveCommand"><span class="annot"><span class="annottext">runInteractiveCommand :: String -&gt; IO (Handle, Handle, Handle, ProcessHandle)
</span><a href="System.Process.html#runInteractiveCommand"><span class="hs-identifier hs-var hs-var">runInteractiveCommand</span></a></span></span><span> </span><span id="local-6989586621679048306"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048306"><span class="hs-identifier hs-var">string</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-961"></span><span>  </span><span class="annot"><span class="annottext">String
-&gt; CreateProcess -&gt; IO (Handle, Handle, Handle, ProcessHandle)
</span><a href="System.Process.html#runInteractiveProcess1"><span class="hs-identifier hs-var">runInteractiveProcess1</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;runInteractiveCommand&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CreateProcess
</span><a href="System.Process.html#shell"><span class="hs-identifier hs-var">shell</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048306"><span class="hs-identifier hs-var">string</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-962"></span><span>
</span><span id="line-963"></span><span>
</span><span id="line-964"></span><span class="hs-comment">-- ----------------------------------------------------------------------------</span><span>
</span><span id="line-965"></span><span class="hs-comment">-- runInteractiveProcess</span><span>
</span><span id="line-966"></span><span>
</span><span id="line-967"></span><span class="hs-comment">--TODO: in a later release {-# DEPRECATED runInteractiveCommand &quot;Use 'createProcess' instead&quot; #-}</span><span>
</span><span id="line-968"></span><span>
</span><span id="line-969"></span><span class="hs-comment">{- | Runs a raw command, and returns 'Handle's that may be used to communicate
     with the process via its @stdin@, @stdout@ and @stderr@ respectively.

    For example, to start a process and feed a string to its stdin:

&gt;   (inp,out,err,pid) &lt;- runInteractiveProcess &quot;...&quot;
&gt;   forkIO (hPutStr inp str)
-}</span><span>
</span><span id="line-977"></span><span class="annot"><a href="System.Process.html#runInteractiveProcess"><span class="hs-identifier hs-type">runInteractiveProcess</span></a></span><span>
</span><span id="line-978"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>                   </span><span class="hs-comment">-- ^ Filename of the executable (see 'RawCommand' for details)</span><span>
</span><span id="line-979"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span>                   </span><span class="hs-comment">-- ^ Arguments to pass to the executable</span><span>
</span><span id="line-980"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>             </span><span class="hs-comment">-- ^ Optional path to the working directory</span><span>
</span><span id="line-981"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>    </span><span class="hs-comment">-- ^ Optional environment (otherwise inherit)</span><span>
</span><span id="line-982"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-983"></span><span>
</span><span id="line-984"></span><span id="runInteractiveProcess"><span class="annot"><span class="annottext">runInteractiveProcess :: String
-&gt; [String]
-&gt; Maybe String
-&gt; Maybe [(String, String)]
-&gt; IO (Handle, Handle, Handle, ProcessHandle)
</span><a href="System.Process.html#runInteractiveProcess"><span class="hs-identifier hs-var hs-var">runInteractiveProcess</span></a></span></span><span> </span><span id="local-6989586621679048304"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048304"><span class="hs-identifier hs-var">cmd</span></a></span></span><span> </span><span id="local-6989586621679048303"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048303"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621679048302"><span class="annot"><span class="annottext">Maybe String
</span><a href="#local-6989586621679048302"><span class="hs-identifier hs-var">mb_cwd</span></a></span></span><span> </span><span id="local-6989586621679048301"><span class="annot"><span class="annottext">Maybe [(String, String)]
</span><a href="#local-6989586621679048301"><span class="hs-identifier hs-var">mb_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-985"></span><span>  </span><span class="annot"><span class="annottext">String
-&gt; CreateProcess -&gt; IO (Handle, Handle, Handle, ProcessHandle)
</span><a href="System.Process.html#runInteractiveProcess1"><span class="hs-identifier hs-var">runInteractiveProcess1</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;runInteractiveProcess&quot;</span></span><span>
</span><span id="line-986"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; CreateProcess
</span><a href="System.Process.html#proc"><span class="hs-identifier hs-var">proc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048304"><span class="hs-identifier hs-var">cmd</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048303"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cwd :: Maybe String
</span><a href="System.Process.Common.html#cwd"><span class="hs-identifier hs-var">cwd</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe String
</span><a href="#local-6989586621679048302"><span class="hs-identifier hs-var">mb_cwd</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">env :: Maybe [(String, String)]
</span><a href="System.Process.Common.html#env"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe [(String, String)]
</span><a href="#local-6989586621679048301"><span class="hs-identifier hs-var">mb_env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-987"></span><span>
</span><span id="line-988"></span><span class="annot"><a href="System.Process.html#runInteractiveProcess1"><span class="hs-identifier hs-type">runInteractiveProcess1</span></a></span><span>
</span><span id="line-989"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-990"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Process.Common.html#CreateProcess"><span class="hs-identifier hs-type">CreateProcess</span></a></span><span>
</span><span id="line-991"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">,</span><span class="annot"><a href="System.Process.Common.html#ProcessHandle"><span class="hs-identifier hs-type">ProcessHandle</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-992"></span><span id="runInteractiveProcess1"><span class="annot"><span class="annottext">runInteractiveProcess1 :: String
-&gt; CreateProcess -&gt; IO (Handle, Handle, Handle, ProcessHandle)
</span><a href="System.Process.html#runInteractiveProcess1"><span class="hs-identifier hs-var hs-var">runInteractiveProcess1</span></a></span></span><span> </span><span id="local-6989586621679048300"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048300"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span id="local-6989586621679048299"><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048299"><span class="hs-identifier hs-var">cmd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-993"></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621679048298"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048298"><span class="hs-identifier hs-var">mb_in</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048297"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048297"><span class="hs-identifier hs-var">mb_out</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048296"><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048296"><span class="hs-identifier hs-var">mb_err</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048295"><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048295"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span>
</span><span id="line-994"></span><span>      </span><span class="annot"><span class="annottext">String
-&gt; CreateProcess
-&gt; IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
</span><a href="System.Process.Internals.html#createProcess_"><span class="hs-identifier hs-var">createProcess_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048300"><span class="hs-identifier hs-var">fun</span></a></span><span>
</span><span id="line-995"></span><span>           </span><span class="annot"><span class="annottext">CreateProcess
</span><a href="#local-6989586621679048299"><span class="hs-identifier hs-var">cmd</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">std_in :: StdStream
</span><a href="System.Process.Common.html#std_in"><span class="hs-identifier hs-var">std_in</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#CreatePipe"><span class="hs-identifier hs-var">CreatePipe</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-996"></span><span>                </span><span class="annot"><span class="annottext">std_out :: StdStream
</span><a href="System.Process.Common.html#std_out"><span class="hs-identifier hs-var">std_out</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#CreatePipe"><span class="hs-identifier hs-var">CreatePipe</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-997"></span><span>                </span><span class="annot"><span class="annottext">std_err :: StdStream
</span><a href="System.Process.Common.html#std_err"><span class="hs-identifier hs-var">std_err</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StdStream
</span><a href="System.Process.Common.html#CreatePipe"><span class="hs-identifier hs-var">CreatePipe</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-998"></span><span>  </span><span class="annot"><span class="annottext">(Handle, Handle, Handle, ProcessHandle)
-&gt; IO (Handle, Handle, Handle, ProcessHandle)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle -&gt; Handle
forall a. HasCallStack =&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromJust"><span class="hs-identifier hs-var">fromJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048298"><span class="hs-identifier hs-var">mb_in</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe Handle -&gt; Handle
forall a. HasCallStack =&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromJust"><span class="hs-identifier hs-var">fromJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048297"><span class="hs-identifier hs-var">mb_out</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe Handle -&gt; Handle
forall a. HasCallStack =&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromJust"><span class="hs-identifier hs-var">fromJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
</span><a href="#local-6989586621679048296"><span class="hs-identifier hs-var">mb_err</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048295"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-999"></span><span>
</span><span id="line-1000"></span><span>
</span><span id="line-1001"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-1002"></span><span class="hs-comment">-- system &amp; rawSystem</span><span>
</span><span id="line-1003"></span><span>
</span><span id="line-1004"></span><span class="hs-comment">--TODO: in a later release {-# DEPRECATED system &quot;Use 'callCommand' (or 'spawnCommand' and 'waitForProcess') instead&quot; #-}</span><span>
</span><span id="line-1005"></span><span>
</span><span id="line-1006"></span><span class="hs-comment">{-|
Computation @system cmd@ returns the exit code produced when the
operating system runs the shell command @cmd@.

This computation may fail with one of the following
'System.IO.Error.IOErrorType' exceptions:

[@PermissionDenied@]
The process has insufficient privileges to perform the operation.

[@ResourceExhausted@]
Insufficient resources are available to perform the operation.

[@UnsupportedOperation@]
The implementation does not support system calls.

On Windows, 'system' passes the command to the Windows command
interpreter (@CMD.EXE@ or @COMMAND.COM@), hence Unixy shell tricks
will not work.

On Unix systems, see 'waitForProcess' for the meaning of exit codes
when the process died as the result of a signal.
-}</span><span>
</span><span id="line-1029"></span><span class="annot"><a href="System.Process.html#system"><span class="hs-identifier hs-type">system</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ExitCode"><span class="hs-identifier hs-type">ExitCode</span></a></span><span>
</span><span id="line-1030"></span><span id="system"><span class="annot"><span class="annottext">system :: String -&gt; IO ExitCode
</span><a href="System.Process.html#system"><span class="hs-identifier hs-var hs-var">system</span></a></span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; IO ExitCode
forall a. IOException -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioException"><span class="hs-identifier hs-var">ioException</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOException -&gt; String -&gt; IOException
</span><a href="../../base/src/System.IO.Error.html#ioeSetErrorString"><span class="hs-identifier hs-var">ioeSetErrorString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOErrorType
-&gt; String -&gt; Maybe Handle -&gt; Maybe String -&gt; IOException
</span><a href="../../base/src/System.IO.Error.html#mkIOError"><span class="hs-identifier hs-var">mkIOError</span></a></span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="../../base/src/GHC.IO.Exception.html#InvalidArgument"><span class="hs-identifier hs-var">InvalidArgument</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;system&quot;</span></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;null command&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-1031"></span><span class="annot"><a href="System.Process.html#system"><span class="hs-identifier hs-var">system</span></a></span><span> </span><span id="local-6989586621679048292"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048292"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1032"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621679048291"><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048291"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String
-&gt; CreateProcess
-&gt; IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
</span><a href="System.Process.Internals.html#createProcess_"><span class="hs-identifier hs-var">createProcess_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;system&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CreateProcess
</span><a href="System.Process.html#shell"><span class="hs-identifier hs-var">shell</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048292"><span class="hs-identifier hs-var">str</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delegate_ctlc :: Bool
</span><a href="System.Process.Common.html#delegate_ctlc"><span class="hs-identifier hs-var">delegate_ctlc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1033"></span><span>  </span><span class="annot"><span class="annottext">ProcessHandle -&gt; IO ExitCode
</span><a href="System.Process.html#waitForProcess"><span class="hs-identifier hs-var">waitForProcess</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048291"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-1034"></span><span>
</span><span id="line-1035"></span><span>
</span><span id="line-1036"></span><span class="hs-comment">--TODO: in a later release {-# DEPRECATED rawSystem &quot;Use 'callProcess' (or 'spawnProcess' and 'waitForProcess') instead&quot; #-}</span><span>
</span><span id="line-1037"></span><span>
</span><span id="line-1038"></span><span class="hs-comment">{-|
The computation @'rawSystem' /cmd/ /args/@ runs the operating system command
@/cmd/@ in such a way that it receives as arguments the @/args/@ strings
exactly as given, with no funny escaping or shell meta-syntax expansion.
It will therefore behave more portably between operating systems than 'system'.

The return codes and possible failures are the same as for 'system'.
-}</span><span>
</span><span id="line-1046"></span><span class="annot"><a href="System.Process.html#rawSystem"><span class="hs-identifier hs-type">rawSystem</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ExitCode"><span class="hs-identifier hs-type">ExitCode</span></a></span><span>
</span><span id="line-1047"></span><span id="rawSystem"><span class="annot"><span class="annottext">rawSystem :: String -&gt; [String] -&gt; IO ExitCode
</span><a href="System.Process.html#rawSystem"><span class="hs-identifier hs-var hs-var">rawSystem</span></a></span></span><span> </span><span id="local-6989586621679048290"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048290"><span class="hs-identifier hs-var">cmd</span></a></span></span><span> </span><span id="local-6989586621679048289"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048289"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1048"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Maybe Handle
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621679048288"><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048288"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String
-&gt; CreateProcess
-&gt; IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
</span><a href="System.Process.Internals.html#createProcess_"><span class="hs-identifier hs-var">createProcess_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rawSystem&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; CreateProcess
</span><a href="System.Process.html#proc"><span class="hs-identifier hs-var">proc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679048290"><span class="hs-identifier hs-var">cmd</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679048289"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delegate_ctlc :: Bool
</span><a href="System.Process.Common.html#delegate_ctlc"><span class="hs-identifier hs-var">delegate_ctlc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1049"></span><span>  </span><span class="annot"><span class="annottext">ProcessHandle -&gt; IO ExitCode
</span><a href="System.Process.html#waitForProcess"><span class="hs-identifier hs-var">waitForProcess</span></a></span><span> </span><span class="annot"><span class="annottext">ProcessHandle
</span><a href="#local-6989586621679048288"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-1050"></span></pre></body></html>